STINNER Victor added the comment:

compiler_add_o() uses an heuristic to compare and merge duplicated constants. 
It has special cases for float and complex numbers, but it's not designed to 
handle more types.

Funny, I had the same isue last week why I added support for tuple and 
frozenset "constants" in AST. I had to explicitly support these types in 
compiler_add_o().

I see two options:

(1) share code between compiler_add_o() and code_richcompare() to ensure that 1 
and 1.0 constants are not seen as equal
(2) modify compiler_add_o() to never merge code objects, always considere them 
as unequal

For (2), there is a minor technical issue: you have to generate an unique key 
for the dictionary.

I prefer option (1) for consistency.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25843>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to