'isimmutable' and 'ImmutableNester'

Frank-Rene Schäfer fschaef at gmail.com
Tue Nov 12 04:39:49 EST 2013


> All you've done is proven that you can subvert things. By fiddling
> with __hash__, __eq__, and so on, you can make sets and dicts behave
> very oddly. Means nothing.

To the contrary, it means everything about what 'isimmutable' could
contribute: security against advert or inadvert insertion of mutable objects.


2013/11/11  <random832 at fastmail.us>:
>> A built-in function 'isimmutable()' shall tell efficiently whether the
>> object
>> of concern is mutable or not.
>
> What's the benefit over attempting to hash() the object?
>
> copy.deepcopy already has special case for int, string, and tuples
> (including tuples that do and do not have mutable members) - could what
> you need be accomplished by overriding __copy__ and __deepcopy__ in your
> custom class to return itself if it is immutable?



More information about the Python-list mailing list