Performance of int/long in Python 3

Ian Kelly ian.g.kelly at gmail.com
Wed Apr 3 12:30:45 EDT 2013


On Wed, Apr 3, 2013 at 5:52 AM, Dave Angel <davea at davea.name> wrote:
> I'm also puzzled.  I thought that the sort algorithm used a hash of all the
> items to be sorted, and only reverted to a raw comparison of the original
> values when the hash collided.  Is that not the case?  Or is the code you
> post here only used when the hash collides?

I think you are mistaken, because I don't see how that could work.  If
the hashes of two items are different then you can assume they are not
equal, but sorting requires a partial ordering comparison, not simply
an equality comparison.  You cannot determine which item is less or
greater than the other from the hash values alone.



More information about the Python-list mailing list