confusing doc: mutable and hashable

Arnaud Delobelle arnodel at gmail.com
Sun Apr 29 02:40:51 EDT 2012


(sent from my phone)
On Apr 28, 2012 7:36 PM, "Chris Rebert" <clp2 at rebertia.com> wrote:
> Correct. Pedantically, you can define __hash__() on mutable objects;
> it's just not very useful or sensible, so people generally don't.

I find it's fine to define __hash__ on mutable objects as long as __eq__
only relies on immutable state (and then so should __hash__ of course).  A
typical example would be an object that does some caching.

-- 
Arnaud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120429/9cea4011/attachment.html>


More information about the Python-list mailing list