I use attrs instead of pydantic

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • mashumaro

    Fast and well tested serialization library

  • Having run into these issues with Pydantic, we've been using Mashumaro[1], which, while not having all the bells and whistles of Pydantic, has served us pretty well.

    1: https://github.com/Fatal1ty/mashumaro

  • datamodel-code-generator

    Pydantic model and dataclasses.dataclass generator for easy conversion of JSON, OpenAPI, JSON Schema, and YAML data sources.

  • had generally good experience creating typed wrappers for api's with json-schema-to-pydantic[0] converter

    [0] https://github.com/koxudaxi/datamodel-code-generator

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • typing

    Python static typing home. Hosts the documentation and a user help forum.

  • Mypy allows that because initial versions of PEP-484 allowed that. This has changed; here's the current wording on the PEP:

    > This is no longer the recommended behavior. Type checkers should move towards requiring the optional type to be made explicit.

    https://www.python.org/dev/peps/pep-0484/#id29

  • pydantic

    Data validation using Python type hints

  • >I didn't know about the performance differences. Sam Colvin strikes me as very thorough and the community is very involved, so I don't think the benchmarks claiming pydantic faster than attrs is wrong. I know pydantic uses cython under the hood (no idea what) - is it possible that environmental differences are causing the discrepancy?

    If I'm reading this issue right the benchamrks in the pydantic docs are misleading https://github.com/samuelcolvin/pydantic/pull/1568

    Also

  • cattrs

    Composable custom class converters for attrs.

  • ```

    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.

    [1] https://github.com/Tinche/cattrs/issues/149

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts