[pypy-svn] r41803 - in pypy/dist/pypy: config objspace/std
arigo at codespeak.net
arigo at codespeak.net
Mon Apr 2 14:57:51 CEST 2007
Author: arigo
Date: Mon Apr 2 14:57:49 2007
New Revision: 41803
Modified:
pypy/dist/pypy/config/pypyoption.py
pypy/dist/pypy/objspace/std/objspace.py
Log:
A version of BINARY_SUBSCR that special-cases 'list[integer]'.
Not enabled by default, measuring...
Modified: pypy/dist/pypy/config/pypyoption.py
==============================================================================
--- pypy/dist/pypy/config/pypyoption.py (original)
+++ pypy/dist/pypy/config/pypyoption.py Mon Apr 2 14:57:49 2007
@@ -226,6 +226,9 @@
BoolOption("optimized_int_add",
"special case the addition of two integers in BINARY_ADD",
default=False),
+ BoolOption("optimized_list_getitem",
+ "special case the 'list[integer]' expressions",
+ default=False),
BoolOption("oldstyle",
"specify whether the default metaclass should be classobj",
Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py (original)
+++ pypy/dist/pypy/objspace/std/objspace.py Mon Apr 2 14:57:49 2007
@@ -88,6 +88,20 @@
w_result = f.space.add(w_1, w_2)
f.pushvalue(w_result)
+ if self.config.objspace.std.optimized_list_getitem:
+ def BINARY_SUBSCR(f, *ignored):
+ w_2 = f.popvalue()
+ w_1 = f.popvalue()
+ if type(w_1) is W_ListObject and type(w_2) is W_IntObject:
+ try:
+ w_result = w_1.wrappeditems[w_2.intval]
+ except IndexError:
+ raise OperationError(f.space.w_IndexError,
+ f.space.wrap("list index out of range"))
+ else:
+ w_result = f.space.getitem(w_1, w_2)
+ f.pushvalue(w_result)
+
def CALL_LIKELY_BUILTIN(f, oparg, *ignored):
from pypy.module.__builtin__ import OPTIMIZED_BUILTINS, Module
from pypy.objspace.std.dictmultiobject import W_DictMultiObject
More information about the Pypy-commit
mailing list