[issue2603] Make range __eq__ work

Alexander Belopolsky report at bugs.python.org
Thu Apr 17 05:11:41 CEST 2008


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

On Wed, Apr 16, 2008 at 9:24 PM, Benjamin Peterson wrote:
..
> Why not just hash a tuple?

There are a few reasons, but neither is good enough to have another
round of code review :-)

1. It is strange to have the hash function allocate new objects.  If
that was a type frequently used as a dict key, I would be concerned
about a possibility that dictionary lookup may trigger gc.

2. While reproducing hash(tuple) is a good starting point, there may
be a reason to choose different values for the magic constants.

3. If you don't want to mess with hash(tuple) complexity, a simple xor
of start/stop/step hashes (maybe with a check to prevent accidental -1
return) should be good enough.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2603>
__________________________________


More information about the Python-bugs-list mailing list