Dataclasses versus plain dicts

Back to list2026-05-27
You

Is there a real reason to use dataclasses over dicts for internal data?

ChatGPT

Typos become errors instead of silent None, and the field list is documentation that cannot drift. The cost is a small allocation overhead, which matters only in the hottest loops. With slots=True even that mostly disappears.

You
budget-2025.png
You

Should the venv see system site-packages?

ChatGPT

No, except when you deliberately depend on a system build of something heavy like GTK bindings. Inheriting site-packages is the most common source of "works on my machine", because the environment is no longer described by requirements alone.

You

How specific should except clauses be?

ChatGPT

Specific enough that an unexpected failure still crashes. except Exception around an entire request handler is fine if it logs and re-raises in development; the same clause around three lines of parsing will swallow the typo that broke them.