bpo-34100: compile: Re-enable frozenset merging (GH-10760)

This reverts commit 1005c84535.
This commit is contained in:
INADA Naoki 2018-11-29 00:58:46 +09:00 committed by Victor Stinner
parent 1cdfcfc984
commit f7e4d3642f
2 changed files with 65 additions and 2 deletions

View file

@ -615,6 +615,14 @@ if 1:
self.check_constant(f1, Ellipsis)
self.assertEqual(repr(f1()), repr(Ellipsis))
# Merge constants in tuple or frozenset
f1, f2 = lambda: "not a name", lambda: ("not a name",)
f3 = lambda x: x in {("not a name",)}
self.assertIs(f1.__code__.co_consts[1],
f2.__code__.co_consts[1][0])
self.assertIs(next(iter(f3.__code__.co_consts[1])),
f2.__code__.co_consts[1])
# {0} is converted to a constant frozenset({0}) by the peephole
# optimizer
f1, f2 = lambda x: x in {0}, lambda x: x in {0}