This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients docs@python, terry.reedy
Date 2012-01-04.00:40:52
SpamBayes Score 4.9647747e-07
Marked as misclassified No
Message-id <1325637653.51.0.0128051850964.issue13707@psf.upfronthosting.co.za>
In-reply-to
Content
Current 3.2.2 docs:

id(object) Return the “identity” of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. [model]

hash(object) Return the hash value of the object (if it has one). Hash values are integers. They are used to quickly compare dictionary keys 

Suggestion: change "Hash values are integers. They ..." to
"This should be an integer which is constant for this object during its lifetime. Hash values ..."

Rationale: For builtin class instances, hash values are guaranteed to be constant that long, and only that long, as the default hash(ob) for object() instances is currently, for my win7, 64 bit, 3.2.2 CPython, id(ob) // 16 (the minimum object size). User class instance hashes (with custom __hash__) *should* have the same lifetime. But since Python cannot enforce that, I did not say 'guaranteed'.

User code should *not* depend on a longer lifetime, just as for id() output. It seems worth implying that, as for id(), because (based on recent pydev discussion) people seems to be prone to over-generalize the current longer-term stability of number and string hashes, which itself may disappear in future releases. (see #13703)
History
Date User Action Args
2012-01-04 00:40:53terry.reedysetrecipients: + terry.reedy, docs@python
2012-01-04 00:40:53terry.reedysetmessageid: <1325637653.51.0.0128051850964.issue13707@psf.upfronthosting.co.za>
2012-01-04 00:40:52terry.reedylinkissue13707 messages
2012-01-04 00:40:52terry.reedycreate