Hacker News new | past | comments | ask | show | jobs | submit login

Forget about DataClasses, TypedDict etc. Can't you achieve the same in python with a class and a dict? Is there a difference, other than perhaps being overloaded with options?



A dataclass will get things like __repr__ for free.


Eq, hash, and init is also "free".


There’s also implementation differences. Accessing attributes and methods on a regular class may be slower because (IIRC) it has to do a lookup on each instance’s dict, whereas I believe dataclass implementation is more optimized (I’ve clearly forgotten the details).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: