Caelyn McAulay added the comment:
Here is a patch to add the requested documentation to code.h - I expanded it to
specify (as per the conversation in this issue) that co_name is used in both
hash and comparisons while co_firstlineno is used only in comparisons.
I do not attempt explain the
Roundup Robot added the comment:
New changeset 0e35cef1d984 by Andrew Kuchling in branch 'default':
#11983: update comment to describe which fields are used and why.
http://hg.python.org/cpython/rev/0e35cef1d984
--
nosy: +python-dev
___
Python
A.M. Kuchling added the comment:
Thanks for the patch!
--
assignee: - akuchling
nosy: +akuchling
resolution: - fixed
stage: - committed/rejected
status: open - closed
versions: +Python 3.5 -Python 3.3
___
Python tracker rep...@bugs.python.org
Eugene Toder added the comment:
If you add co_firstlineno into code_hash you can say something like
/* The rest isn't used in hash and comparisons, except
co_name and co_firstlineno, which are preserved for
tracebacks and debuggers. */
(Otherwise you'd need to explain why co_firstlineno
Brett Cannon added the comment:
I have no issue with the current behaviour, so it sounds like the source
comment just needs updating. Care to suggest some wording, Eugene?
--
___
Python tracker rep...@bugs.python.org
Changes by Brett Cannon br...@python.org:
--
nosy: -brett.cannon
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11983
___
___
Python-bugs-list
Antoine Pitrou added the comment:
It doesn't actually fix the bug and makes hash inconsistent with cmp.
The only constraint is that a == b imply hash(a) == hash(b). But the converse
doesn't have to be true, i.e. if it perfectly possible to have hash(a) ==
hash(b) and a != b (pretty much by
Antoine Pitrou added the comment:
Woops, I saw Brett unnosied himself, sorry for nosying him by mistake.
--
nosy: -brett.cannon
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11983
___
Brett Cannon added the comment:
Making as pending for someone to prove my fix is bad for the problem (since it
passes an explicit test), else I will close it in the near-ish future.
--
nosy: +brett.cannon
status: open - pending
___
Python tracker
Eugene Toder added the comment:
My comment will make more sense if you follow the links that I provided.
Brett's check-in (http://hg.python.org/cpython-fullhistory/rev/8127a55a57cb)
says that it fixes bug #1190011
(http://www.mail-archive.com/python-bugs-list@python.org/msg02440.html). The
Eugene Toder elto...@gmail.com added the comment:
It appears that
* co_name was added to hash and cmp in this check-in by Guido:
http://hg.python.org/cpython-fullhistory/diff/525b2358721e/Python/compile.c
I think the reason was to preserve function name when defining multiple
functions with
Eugene Toder elto...@gmail.com added the comment:
Btw, disabling dedup for codes won't be the first exception -- we already avoid
coalescing -0.0 with 0.0 for float and complex, even though they compare equal.
--
___
Python tracker
Éric Araujo mer...@netwok.org added the comment:
What fix would you propose?
--
nosy: +eric.araujo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11983
___
Eugene Toder elto...@gmail.com added the comment:
I would propose changing implementation to match the comment. At a minimum,
remove co_firstlineno comparison. As the last resort, at least change the
comment.
--
___
Python tracker
New submission from Eugene Toder elto...@gmail.com:
A comment in the definition of PyCodeObject in Include/code.h says:
/* The rest doesn't count for hash or comparisons */
which, I think, makes a lot of sense. The implementation doesn't follow this
comment, though. code_hash actually
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
nosy: +rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11983
___
___
16 matches
Mail list logo