[C++-sig] mutable object has bogus __hash__
Matthew Scouten (TT)
Matthew.Scouten at tradingtechnologies.com
Tue Nov 4 20:18:59 CET 2008
I looks at what it would take to write proper hash functions. These
classes have ridiculously complicated equality operators. I am going to
throw a type error and any users who don't like it can bite me.
Thanks guys.
-----Original Message-----
From:
cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com at python.org
[mailto:cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com at py
thon.org] On Behalf Of Alex Mohr
Sent: Tuesday, November 04, 2008 11:19 AM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] mutable object has bogus __hash__
> I would like to have the __hash__ not exist. These objects are mutable
> and should NOT be used as keys. Is there a way to hide it? If I have
> them throw NotImplemented will python do something sensible with that?
Python raises a TypeError for unhashable things:
>>> [1,2,3].__hash__()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list objects are unhashable
(You get the same with hash([1,2,3]) of course.)
Alex
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig at python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig
More information about the Cplusplus-sig
mailing list