[issue21782] hashable documentation error: shouldn't mention id

2014-10-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset bfaf434a6f10 by Georg Brandl in branch '3.4':
Closes #21782: the default hash(x) is not exactly id(x) but derived from it.
https://hg.python.org/cpython/rev/bfaf434a6f10

--
nosy: +python-dev
resolution:  - fixed
stage:  - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21782
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21782] hashable documentation error: shouldn't mention id

2014-06-16 Thread Giacomo Alzetta

New submission from Giacomo Alzetta:

The documentation for hashable in the glossary 
(https://docs.python.org/3.4/reference/datamodel.html#object.__hash__) is 
incorrect:

they all compare unequal (except with themselves), **and their hash value is 
their id().**

It is *not* true that their hash is their id (see relevant SO question: 
http://stackoverflow.com/questions/24249729/user-defined-class-hash-and-id-and-doc)

Also the documentation for __hash__ 
(https://docs.python.org/3.4/reference/datamodel.html#object.__hash__) doesn't 
even mention id().

--
assignee: docs@python
components: Documentation
messages: 220746
nosy: Giacomo.Alzetta, docs@python
priority: normal
severity: normal
status: open
title: hashable documentation error: shouldn't mention id
type: enhancement
versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21782
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21782] hashable documentation error: shouldn't mention id

2014-06-16 Thread R. David Murray

R. David Murray added the comment:

The statement is poorly worded.  The id() is the *input* to the hash function 
used to compute the default __hash__.  This is a CPython implementation detail, 
though, so perhaps all mention of it should indeed be dropped.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21782
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21782] hashable documentation error: shouldn't mention id

2014-06-16 Thread Giacomo Alzetta

Giacomo Alzetta added the comment:

their hash value is their id() seems quite clearly stating that:

 class A: pass
... 
 a = A()
 hash(a) == id(a)

should be true, but:

 hash(a) == id(a)
False

(both in python2 and in python3)

The python 2 documentation for the __hash__ special method *does* state that 
the default implementation returns a value derived by id().
I believe there is an inconsistency. In the python2 glossary it should say:

their hash value is derived from their id()

While in python3 it shouldn't mention id() at all, since the documentation for 
__hash__ doesn't mention it at all.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21782
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21782] hashable documentation error: shouldn't mention id

2014-06-16 Thread R. David Murray

R. David Murray added the comment:

Yes, I should have been clearer.  By poorly worded I meant id is involved, 
but the sentence does not correctly describe *how* id is involved.  That is, 
the sentence is wrong as written.

The implementation is the same in both Python2 and Python3, though the source 
code organization and how it becomes the default hash is a bit different.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21782
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com