mastodon.world is one of the many independent Mastodon servers you can use to participate in the fediverse.
Generic Mastodon server for anyone to use.

Server stats:

8.1K
active users

#pydantic

3 posts3 participants0 posts today

🌘 保持 Pydantic 遠離你的網域層
➤ 將 Pydantic 限制在應用程式的邊緣
coderik.nl/posts/keep-pydantic
這篇文章探討了在軟體開發中,避免將 Pydantic 引入過多的層次,特別是網域層的問題。作者分享了自身經驗,說明瞭雖然 Pydantic 在資料驗證方面非常方便,但過度依賴可能導致耦合性增加,影響系統的可維護性和可測試性。文章介紹了使用 Dacite 等工具,將 Pydantic 模型轉換為純粹的 Python 物件,以實現更好的分層和關注點分離。
+ 這篇文章點出了我一直以來遇到的問題,Pydantic 真的很好用,但濫用會導致程式碼變得難以維護。
+ Dacite 聽起來很有用,我會嘗試看看它是否能解決我目前的架構問題。
#軟體架構 #Pydantic #乾淨架構

coderik.nlKeep Pydantic out of your Domain Layer | CoderikStop Pydantic leaking into your domain layer. Use lightweight mappers or dacite to convert Pydantic models into pure old python dataclasses and keep your domain layer free of third-party libraries.

Нагрузочное тестирование на Python и Locust с запуском на CI/CD

Разбираемся, как организовать нагрузочное тестирование на Python с Locust — с сидинговыми сценариями , кастомными API-клиентами на HTTPX, конфигурацией через Pydantic и автоматическим запуском в GitHub Actions . Всё — на практике, с архитектурой, фреймворком и публикацией отчётов в GitHub Pages.

habr.com/ru/articles/929136/

ХабрНагрузочное тестирование на Python и Locust с запуском на CI/CDВведение В этой статье я наглядно покажу, как организовать нагрузочное тестирование с использованием Python и фреймворка Locust , опираясь на инженерные практики и удобную архитектуру. Цель статьи —...

If you ever ask why it’s worth updating #Python dependencies from time to time, #Pydantic serves as a nice example with the performance boost introduced. I actually could see it, given the complexity of models I deal with on a daily basis.

> Recent memory usage optimizations are most relevant for projects with lots of models, particularly those with nested/reused models. In these cases, you can expect a 2-5x reduction in memory usage.

#DailyPythonista
pydantic.dev/articles/pydantic

Pydantic v2.11
pydantic.devPydantic v2.11 | PydanticPydantic v2.11 release highlights

Si vous utilisez #Pydantic, et que vous êtes confronté·es à des problèmes d'allocation mémoire lors de chargement de #JSON volumineux, voici une exemple de comment contourner le problème, en utilisant la bibliothèque #Python ijson.
pythonspeed.com/articles/pydan

Python⇒Speed · Loading Pydantic models from JSON without running out of memoryPydantic’s JSON loading uses a huge amount of memory; here’s how to reduce it.

🌖 從 JSON 加載 Pydantic 模型,避免記憶體不足
➤ 解決 Pydantic 解析大型 JSON 檔案的記憶體瓶頸
pythonspeed.com/articles/pydan
本文探討了使用 Pydantic 從大型 JSON 文件中載入數據時,記憶體使用量過高的問題。作者介紹了兩種降低記憶體佔用的方法:一是使用增量 JSON 解析器 ijson,二是利用 `dataclass` 搭配 `slots`,以更有效率的方式儲存物件。透過實測,作者展示了不同方法的記憶體使用量差異,並建議 Pydantic 開發者考慮在未來版本中優化記憶體管理。
+ 這篇文章很有幫助,我一直遇到 Pydantic 解析大型 JSON 的問題,現在知道可以嘗試 ijson 和 dataclass 了!
+ 作者提出的解決方案很實用,而且提供了具體的程式碼範例,方便直接應用。希望 Pydantic 未來能內建這些優化功能。
#Python效能 #Pydantic #JSON解析 #記憶體管理

Python⇒Speed · Loading Pydantic models from JSON without running out of memoryPydantic’s JSON loading uses a huge amount of memory; here’s how to reduce it.

Did some benchmarking of how fast #Python (3.13) w/ async #httpx and #Pydantic could query a JSON API vs. #GoLang (both including unmarshalling to native types and some regex validation).

While Python could do about 2.5k requests per second against localhost when running singlecore, Go did 10k.

However, not only is Go "only" 4× as fast, these differences quickly shrink to 30 % when you introduce an actual network between the hosts, and become irrelevant with rate limiting & DDoS protection.

Как я строю удобную инфраструктуру вокруг Python-проектов: линтеры, Poetry, CI/CD и Docker

Poetry вместо pip, Ruff вместо flake8, FastAPI вместо ручной документации. Что реально упрощает жизнь Python-разработчику сегодня — на примерах и с реальными конфигами.

habr.com/ru/articles/904844/

ХабрКак я строю удобную инфраструктуру вокруг Python-проектов: линтеры, Poetry, CI/CD и DockerСкорее всего, каждый из вас сталкивался с такой ситуацией, когда на просторах интернета видишь статью или видео о новой модной штуке, которую обязательно надо попробовать в своих проектах, но...