I've wasted way too much time for this, which is surely not a Python bug,
not something that surprised me a lot.
I stupidly gave for granted that adding an object to a set would first
check if there are equal elements inside, and then add it.
As shown below this is not clearly the case..
Is it
On Fri, Dec 9, 2011 at 3:34 AM, Andrea Crotti andrea.crott...@gmail.com wrote:
I've wasted way too much time for this, which is surely not a Python bug,
not something that surprised me a lot.
I stupidly gave for granted that adding an object to a set would first
check if there are equal
Andrea Crotti wrote:
I've wasted way too much time for this, which is surely not a Python bug,
not something that surprised me a lot.
I stupidly gave for granted that adding an object to a set would first
check if there are equal elements inside, and then add it.
As shown below this is
Chris Angelico wrote:
It checks for equality using hashes. By default, in Python 2, objects'
hashes are their ids - meaning that no two of them hash alike, and
you'll get duplicates in your set. (In Python 3, the default appears
to be that they're unhashable and hence can't go into the set at
On Fri, Dec 9, 2011 at 4:32 AM, Peter Otten __pete...@web.de wrote:
The only thing that has changed (in 2.7) is the algorithm to calculate the
hash value. The bits are rotated to turn the four least significant bits
into the most signicant ones. According to a comment in Objects/objects.c
the
Chris Angelico wrote:
On Fri, Dec 9, 2011 at 4:32 AM, Peter Otten __pete...@web.de wrote:
The only thing that has changed (in 2.7) is the algorithm to calculate
the hash value. The bits are rotated to turn the four least significant
bits into the most signicant ones. According to a comment in
Chris Angelico ros...@gmail.com wrote:
On Fri, Dec 9, 2011 at 4:32 AM, Peter Otten __pete...@web.de wrote:
The only thing that has changed (in 2.7) is the algorithm to
calculate the hash value. The bits are rotated to turn the four least
significant bits into the most signicant ones.
On 12/8/2011 1:54 PM, Duncan Booth wrote:
Yes, the documentation describes this although I don't think anything
highlights that it is a change from Python 2.x:
[http://docs.python.org/py3k/reference/datamodel.html]
The Python 3 docs are 're-based' on 3.0, with change notes going forward