this post was submitted on 04 Jul 2025
10 points (91.7% liked)

Python

7268 readers
44 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
top 4 comments
sorted by: hot top controversial new old
[–] Endmaker@ani.social 8 points 1 day 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 7 points 1 day ago (1 children)

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

If you don't need that go with dataclasses

[–] eager_eagle@lemmy.world 2 points 1 day ago

I was going to comment this too

[–] arjache@fedia.io 3 points 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.