[issue34100] Same integers in a tuple of constant literals are not merged

2018-07-12 Thread STINNER Victor
STINNER Victor added the comment: Honestly, I don't think that it's a bug. We might enhance Python 3.8 to reduce constants duplication, but there is no need to "fix" Python 3.7. -- ___ Python tracker __

[issue34100] Same integers in a tuple of constant literals are not merged

2018-07-11 Thread INADA Naoki
INADA Naoki added the comment: FYI, same constants are shared even when they are in different tuples on 3.6. For modules having large constant table containing large integer or floats, non name-like string, and bytes are affected significantly. -- ___

[issue34100] Same integers in a tuple of constant literals are not merged

2018-07-11 Thread Tim Peters
Tim Peters added the comment: Fine, Serhiy, so reword it a tiny bit: it's nice if a code object's co_consts vector references as few distinct objects as possible. Still a matter of pragmatics, not of correctness. -- ___ Python tracker

[issue34100] Same integers in a tuple of constant literals are not merged

2018-07-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The co_consts vector is already as short as possible, except cases when tuples are created at code generation time, but this is not related to this issue (see issue33318 and issue33325). >>> def f(): ... a = (1.0, 1.0) ... b = (1.0, 1.0) ... >>> f

[issue34100] Same integers in a tuple of constant literals are not merged

2018-07-11 Thread INADA Naoki
INADA Naoki added the comment: OK, unless example code this regression affects seriously is shown, I target only 3.8. -- versions: -Python 3.7 ___ Python tracker ___ ___

[issue34100] Same integers in a tuple of constant literals are not merged

2018-07-11 Thread Tim Peters
Tim Peters added the comment: The language doesn't define anything about this - any program relying on accidental identity is in error itself. Still, it's nice if a code object's co_consts vector is as short as reasonably possible. That's a matter of pragmatics, not of correctness. ---

[issue34100] Same integers in a tuple of constant literals are not merged

2018-07-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This is not only with integers. >>> a = ((1, 2), (1, 2)) >>> a[0] is a[1] False >>> a = ('@#$', '@#$') >>> a[0] is a[1] False >>> a = (1.0, 1.0) >>> a[0] is a[1] False The only exception is short ASCII identifier-like strings (as a side effect of interning

[issue34100] Same integers in a tuple of constant literals are not merged

2018-07-11 Thread INADA Naoki
Change by INADA Naoki : -- components: +Interpreter Core keywords: +3.7regression title: Python doesn't intern integers in a tuple of constant literals -> Same integers in a tuple of constant literals are not merged type: behavior -> resource usage versions: +Python 3.8 __