how to test for atomicity/mutability/hashability?

Christian Heimes lists at cheimes.de
Thu Oct 7 23:28:12 CEST 2010


Am 07.10.2010 22:02, schrieb Chris Rebert:
> On Thu, Oct 7, 2010 at 12:13 PM, kj <no.email at please.post> wrote:
> <snip>
>> It would facilitate the implementation of t() to have a simple test
>> for mutability.  Is there one?
> 
> Non-default hashability is an approximate heuristic:

Except that every user defined class is hashable and mutable by default ;)

>>> class Example(object):
...     pass
...
>>> example = Example()
>>> hash(example)
139810551284624
>>> example.__dict__
{}
>>> example.egg = "spam"
>>> example.__dict__
{'egg': 'spam'}




More information about the Python-list mailing list