classification
Title: Update __hash__ doc
Type: Stage: needs patch
Components: Documentation Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: benjamin.peterson, georg.brandl, terry.reedy
Priority: normal Keywords:

Created on 2008-11-17 21:48 by terry.reedy, last changed 2008-11-17 22:05 by benjamin.peterson. This issue is now closed.

Messages (2)
msg75984 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2008-11-17 21:48
Language/data model/special method names/ __hash__

Sentence 1: "Called for the key object for dictionary operations, and by
the built-in function hash()."

Also called for the members of set and frozenset (and any other hashed
based collection).

Suggestion 1: "Called by the built-in function hash() and for operations
on members or keys of hashed collections. These currently include the
built-in classes set, frozenset, and dict."

Corresponding future-proof changes later in the text:

From "its instances will not be usable as dictionary keys"

to "its instances will not be usable as hashable members or keys".

From "since the dictionary implementation requires"

to "since hashable collection implementations require"
==============================

Sentence 2: "Should return an integer usable as a hash value for
dictionary operations."

I am confused by the qualification 'usable....'.  If it does not
qualify, it is meaningless and should be removed.  If it does qualify,
it should be replaced by what it means.

My impression is that integers of any value are usable since 2.5.

It is also my impression that 2.x specifically requires an int or long.
If so, "Should return an int or long integer." would be clearer.

For 3.0, I don't know what the boundaries are.  A float works, even if
not integral. [bug?] A Fraction does not, even if integral, even though
int(Fraction(n,1)) returns n.
msg75986 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-11-17 22:05
Thanks! Fixed in r67245.
History
Date User Action Args
2008-11-17 22:05:29benjamin.petersonsetstatus: open -> closed
nosy: + benjamin.peterson
resolution: fixed
messages: + msg75986
2008-11-17 21:48:34terry.reedycreate