cattrs
pydantic
Our great sponsors
cattrs | pydantic | |
---|---|---|
7 | 166 | |
750 | 18,226 | |
2.9% | 4.2% | |
8.9 | 9.8 | |
12 days ago | 1 day ago | |
Python | Python | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
cattrs
-
Writing Python like it’s Rust
I'd suggest you look at my cattrs (https://catt.rs) library as a good serde lookalike in Python (sum type support present and getting better), and to use attrs instead of dataclasses in general.
-
Starlite updates March '22 | 2.0 is coming
Pydantic is by far not the only library of its kind, with prominent members of the same class being attrs, cattrs or even plain dataclasses for some use cases.
-
apischema v0.17 - I've developed the fastest typed JSON (de)serialization library, and you can also build your GraphQL schema with it
This month, I've released version 0.17, and it's now blazing fast; there is in fact no more comparison with Pydantic, which more than 5x slower (up to 30x in serialization). It's also faster than alternatives like mashumaro or cattrs. (See the quick benchmark result in documentation, and the code)
-
I use attrs instead of pydantic
```
Cattrs has some problems with generics [1] [2]. Dacite and marshmallow-dataclasses don't support generics well either, with some issues around Union types.
They do work well for simple python types but what I'd like to see is guarantee that the serialisation operation is completely reversible and if not raise warning/exception.
pydantic
-
utype VS pydantic - a user suggested alternative
2 projects | 15 Feb 2024
utype is a concise alternative of pydantic with simplified parameters and usages, supporting both sync/async functions and generators parsing, and capable of using native logic operators to define logical types like AND/OR/NOT, also provides custom type parsing by register mechanism that supports libraries like pydantic, attrs and dataclasses
-
🍹GinAI - Cocktails mixed with generative AI
The easiest implementation I found was to use a PyDantic class for my target schema — and use that as a parameter for the method call to “ChatCompletion.create()”. Here’s a fragment of the GinAI Python classes used.
-
FastStream: Python's framework for Efficient Message Queue Handling
Also, FastStream uses Pydantic to parse input JSON-encoded data into Python objects, making it easy to work with structured data in your applications, so you can serialize your input messages just using type annotations.
-
Introducing FastStream: the easiest way to write microservices for Apache Kafka and RabbitMQ in Python
Pydantic Validation: Leverage Pydantic's validation capabilities to serialize and validate incoming messages
-
FastAPI 0.100.0:Release Notes
Well the performance increase is so huge because pydantic1 is really really slow. And for using rust, I'd have expected more tbh…
I've been benchmarking pydantic v2 against typedload (which I write) and despite the rust, it still manages to be slower than pure python in some benchmarks.
The ones on the website are still about comparing to v1 because v2 was not out yet at the time of the last release.
pydantic's author will refuse to benchmark any library that is faster (https://github.com/pydantic/pydantic/pull/3264 https://github.com/pydantic/pydantic/pull/1525 https://github.com/pydantic/pydantic/pull/1810) and keep boasting about amazing performances.
On pypy, v2 beta was really really really slow.
- Pydantic 2.0
-
[DISCUSSION] What's your favorite Python library, and how has it helped you in your projects?
As for the most utilized and still loved library, that would probably be pydantic, it helps declaring types so convenient - be it dto's, models or just complex arguments - and plays nice with bunch of other libraries from it's own ecosystem.
-
popularity behind pydantic
I did read this ... Pydantic Docs.
-
Guide to Serverless & Lambda Testing — Part 2 — Testing Pyramid
Schema validations logic — I use Pydantic for input validation and schema validation (boto responses, API responses, input validation, etc.) use cases. The Pydantic schema can contain type and value constraint checks or even more complicated logic with the custom validator code.
What are some alternatives?
Cerberus - Lightweight, extensible data validation library for Python
nexe - 🎉 create a single executable out of your node.js apps
msgspec - A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML
SQLAlchemy - The Database Toolkit for Python
sqlmodel - SQL databases in Python, designed for simplicity, compatibility, and robustness.
marshmallow - A lightweight library for converting complex objects to and from simple Python datatypes.
mypy - Optional static typing for Python
pyparsing - Python library for creating PEG parsers [Moved to: https://github.com/pyparsing/pyparsing]
phonenumbers - Python port of Google's libphonenumber
dacite - Simple creation of data classes from dictionaries.
Lark - Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.
beanie - Asynchronous Python ODM for MongoDB