Hacker News new | ask | show | jobs
by joshuamorton 1816 days ago
Please don't do this, there are far better approaches. Use dataclasses/attrs that are frozen for immutable record types.

(Specifically avoid namedtuples unless you're hoisting a tuple to a real record. Record types also being a weird union with a tuple is...oft confusing)

For immutable basic data types, adopt type annotations and prefer to use sequence/iterable and mapping to direct didn't/list types. These provide statically verifiable immutability and also allow begin to encourage useful async-friendly patterns.