TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #397 · 12 ное.

Использование Pydantic сегодня стало нормой, и это правильно. Но иногда на ревью вижу, что используют его не всегда корректно. Например, метод BaseModel.model_dump() по умолчанию не преобразует стандартные типы, такие как datetime, UUID или Decimal, в простой сериализуемый для JSON вид. Тогда пишут кастмоный сериализатор для этих типов чтобы функция json.dump() не падала с ошибкой. import uuid from datetime import datetime from decimal import Decimal from uuid import UUID from pydantic import BaseModel class MyModel(BaseModel): id: UUID date: datetime value: Decimal obj = MyModel( id=uuid.uuid4(), date=datetime.now(), value='1.23' ) print(obj.model_dump()) # не подходит для json.dump # { # 'id': UUID('4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1'), # 'date': datetime.datetime(2025, 12, 12, 12, 12, 12, 111111), # 'value': Decimal('1.23') # } # добавляем свой кастомный сериализатор json.dumps(obj.model_dump(), cls=MySerializer) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2025-12-12T12:12:12.111111', # 'value': '1.23' # } В данном случае класс MySerializer обрабатывает datetime, UUID и Decimal. Например так: class MySerializer(json.JSONEncoder): def default(self, o): if isinstance(o, Decimal): return str(o) elif isinstance(o, datetime): return o.isoformat() elif isinstance(o, UUID): return str(o) return super().default(o) Специально для тех, кто всё еще так делает - в этом нет необходимости! Pydantic может это сделать сам, просто нужно добавить параметр mode="json". json.dumps(obj.model_dump(mode="json")) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2012-12-12T12:12:12.111111', # 'value': '1.23' # } #pydantic#libs

Резултати

Пронајдени 5 слични објави

Пребарај: #nansen

当前筛选 #nansen清除筛选
Crypto M - Crypto News

@CryptoM · Post #64891 · 10.04.2026 г., 07:14

🚀 Ethereum and Chainlink Whales Accumulate Ahead of U.S. CPI Release According to NS3.AI, recent data from Santiment reveals that Ethereum whale wallets have accumulated 500,000 ETH, valued at approximately $1.09 billion, just before the release of the U.S. Consumer Price Index (CPI). In a similar move, Chainlink whale wallets have added 1.89 million LINK, worth about $16.93 million. Meanwhile, Nansen data indicates that Uniswap whale wallets have reduced their holdings by 2.48% over the past week, equivalent to around 90,000 UNI, as traders brace for potential volatility in response to the upcoming inflation report. #Ethereum#Chainlink#Whales#CPI#Uniswap#ETH#LINK#UNI#Inflation#Santiment#Nansen

Venture Village Wall 🦄

@venturevillagewall · Post #4197 · 20.02.2025 г., 07:00

AI Infrastructure Opportunities Emerging! New potential for large-scale AI infrastructure projects! 🤖🔗 While fears of AI replacing humans persist, the reality shows a need for collaboration. Specialized platforms are essential for this interaction. Check out inspirations for creating your own platform here. Additionally, Nansen analysts report that 15,431 wallets experienced significant profit/loss on LIBRA: 86% lost $251M, while a few gained $180M. Recent crypto updates: BTC ETF outflow: $64M, ETH ETF inflow: $19M. During the last 24 hours, 74K traders were liquidated, totaling $139M. Largest liquidation: ETH/USDT at $2M on Binance. #AI#Crypto#VC#Blockchain#Investment#Finance#Tech#DataScience#MarketTrends#Nansen#Wallets#LIBRA#BTC#ETH#Liquidation#ETFs#ProfitLoss#Infrastructure#Innovation#DigitalEconomy#Trading

Venture Village Wall 🦄

@venturevillagewall · Post #4198 · 20.02.2025 г., 10:00

Traders Face Major Losses with LIBRA Coin Nansen research reveals that 86% of LIBRA coin traders lost money, totaling $251 million in investor losses. Meanwhile, insiders profited over $100 million from the token issuance. For more details, visit CoinDesk. #LIBRA#Argentina#Crypto#Investors#Losses#Trading#Nansen#Market#Finance#Tokens#Wealth#Volatility#DeFi#Research#Blockchain#Memecoin#VC#Funds#Loss#Insiders#TradingStrategy

Venture Village Wall 🦄

@venturevillagewall · Post #3837 · 10.01.2025 г., 10:00

Alternatives vs. Altcoin Market Perspectives 🔍 CEO of CryptoQuant, Ki Yun Joo, labels the altcoin market as a 'zero-sum game' due to stagnant capital influx. He suggests only projects with robust use cases can survive. 🚀 Citi analysts forecast a potential alt season with Trump's return, benefiting Ethereum through ETF capital rotation. 📊 Nansen integrates TON blockchain data, offering real-time metrics for the Web3 ecosystem. 💰 CleanSpark becomes the fourth public miner with over 10,000 BTC, reaching this milestone by mining directly. 📈 Ripple aims to list its new RLUSD stablecoin on major exchanges, including ongoing talks with Coinbase and Binance. Bitstamp recently announced support for RLUSD. #Altcoins#Crypto#Ethereum#ETFs#TON#Web3#CleanSpark#Bitcoin#Ripple#RLUSD#Citi#CryptoQuant#Nansen#Blockchain#Mining#Exchange#Bitstamp#CapitalRotation#AltSeason#DonaldTrump#DataAnalytics

Crypto M - Crypto News

@CryptoM · Post #65295 · 12.04.2026 г., 15:15

🚀 Crypto Analyst Manya Releases Research Tool Rankings Crypto analyst manya has released a ranking of personal research tools. According to ChainCatcher, the rankings categorize tools into different levels based on their effectiveness. The S-tier includes Dune and frontrun.pro, while the A-tier features Coinglass, RootData, Drop, MetaSleuth, and DefiLlama. B-tier tools comprise Arkham, Bubblemaps, Dexscreener, Surf, Nansen, and CoinMarketCap. C-tier tools include Cryptorank and others. #CryptoAnalyst#ResearchTools#CryptoRanking#Dune#frontrunpro#Coinglass#RootData#Drop#MetaSleuth#DefiLlama#Arkham#Bubblemaps#Dexscreener#Surf#Nansen#CoinMarketCap#Cryptorank