• Endmaker@ani.social
    link
    fedilink
    English
    arrow-up
    8
    ·
    2 days ago

    Keep it simple, stupid.

    I’d use the built-in dataclass (or something even simpler) where possible. Only when I need more functionalities (e.g. validation) would I switch to using Pydantic model.

  • souperk@reddthat.com
    link
    fedilink
    arrow-up
    7
    ·
    2 days ago

    Depends on what you are trying to accomplish, pydantic is great for encoding/decoding

    If you don’t need that go with dataclasses

  • arjache@fedia.io
    link
    fedilink
    arrow-up
    3
    ·
    1 day ago

    For validation and/or (de)serialization: pydantic.

    Otherwise, dataclasses.

    I also like to replace tuples with NamedTuple, but I tend to use tuples a lot in the first place. It’s generally recommended to use dataclasses instead if you don’t specifically need tuple-like behavior.