Message65571
| Author |
belopolsky |
| Recipients |
amaury.forgeotdarc, belopolsky, benjamin.peterson, georg.brandl, gvanrossum, pitrou |
| Date |
2008年04月17日.03:11:39 |
| SpamBayes Score |
0.029117484 |
| Marked as misclassified |
No |
| Message-id |
<d38f5330804162011h24d17f4fm7e707d595f90313@mail.gmail.com> |
| In-reply-to |
<1208395470.68.0.875423706037.issue2603@psf.upfronthosting.co.za> |
| Content |
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. |
|