[issue6133] LOAD_CONST followed by LOAD_ATTR can be optimized to just be a LOAD_COST
Raymond Hettinger
report at bugs.python.org
Fri May 29 00:13:27 CEST 2009
Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:
I would like to see the current patch finished and recorded here for
reference. But I agree with Martin that changing marshal is a can of
worms. The peepholer is intended to be conservative and should avoid
anything that has some risk of being complicating our lives.
Another approach may be more successful. Here's a rough sketch:
in: LOAD_CONST 5 '{}' LOAD_ATTR 3 'format'
out: LOAD_CONST 8 ('{}','format') LOAD_CONST_ATTR 7.
def LOAD_CONST_ATTR(oparg):
# cache the lookup of '{}.format' in a fast local
x = GETLOCAL(oparg)
if (x == NULL)
UNPACK 2 --> obj, name
bm = getattr(obj, name)
STORE_FAST var
LOAD_FAST var
----------
assignee: -> rhettinger
nosy: +rhettinger
type: -> performance
versions: +Python 2.7, Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6133>
_______________________________________
More information about the Python-bugs-list
mailing list