[Python-Dev] Prospective Peephole Transformation
Raymond Hettinger
python at rcn.com
Sat Feb 19 05:47:01 CET 2005
> I'm very glad you introduced the optimization of building small
> constant tuples at compile-time. IMO, that was a pure win.
It's been out in the wild for a while now with no issues. I'm somewhat
happy with it.
> the transformation isn't semantically correct on the
> face of it.
Well that's the end of that.
What we really need is a clean syntax for specifying a constant
frozenset without compiler transformations of tuples. That would have
the further advantage of letting builtins and globals be used as element
values.
if isinstance(x, {int, float, complex}):
if opcode in {REPEAT, MIN_REPEAT, MAX_REPEAT}:
if (code in {301, 302, 303, 307} and m in {"GET", "HEAD"}:
if op in (ROT_TWO, POP_TOP, LOAD_FAST)
Perhaps something other notation would be better but the idea is
basically the same.
Raymond
More information about the Python-Dev
mailing list