3 ms·
> The lack of a good default immutable data structure means we're stuck using mutable data structures everywhere. Don't completely understand this one. Also,
by mixmastamyk 9y ago
> The lack of a good default immutable data structure means we're stuck using mutable data structures everywhere.
Don't completely understand this one. Also, couldn't you create an immutable-in-practice class?
- yen223 9y agoPython's data structures (with few exceptions) are completely mutable, which means any function can add, modify, or even remove attributes from some object at any time. Look at Django's request object for example. Django, by convention, adds a bunch of attributes to the request object at runtime, via middlewares. This is a problem because a dev can't reason about the shape of request object, without stepping through all the middlewares and figuring out which is doing what. We could use immutable classes internally, but that doesn't solve the problem that external libraries (like Django!) abuse them all over the place.
- jordic 9y agoIf you really need this you can use zope.interface to enforce class immutability..