[pypy-svn] r54284 - in pypy/branch/faster-binop/pypy: config doc/config objspace/std objspace/std/test
arigo at codespeak.net
arigo at codespeak.net
Wed Apr 30 17:59:19 CEST 2008
Author: arigo
Date: Wed Apr 30 17:59:19 2008
New Revision: 54284
Added:
pypy/branch/faster-binop/pypy/doc/config/objspace.std.builtinshortcut.txt (contents, props changed)
pypy/branch/faster-binop/pypy/objspace/std/test/test_builtinshortcut.py (contents, props changed)
Modified:
pypy/branch/faster-binop/pypy/config/pypyoption.py
pypy/branch/faster-binop/pypy/objspace/std/objspace.py
pypy/branch/faster-binop/pypy/objspace/std/test/test_userobject.py
Log:
Introduce this optimization as a config option.
Modified: pypy/branch/faster-binop/pypy/config/pypyoption.py
==============================================================================
--- pypy/branch/faster-binop/pypy/config/pypyoption.py (original)
+++ pypy/branch/faster-binop/pypy/config/pypyoption.py Wed Apr 30 17:59:19 2008
@@ -281,6 +281,9 @@
BoolOption("optimized_list_getitem",
"special case the 'list[integer]' expressions",
default=False),
+ BoolOption("builtinshortcut",
+ "a shortcut for operations between built-in types",
+ default=False),
BoolOption("oldstyle",
"specify whether the default metaclass should be classobj",
@@ -308,8 +311,7 @@
("objspace.std.withmethodcache", True),
# ("objspace.std.withfastslice", True),
("objspace.std.withprebuiltchar", True),
- ("objspace.std.optimized_int_add", True),
- ("objspace.std.optimized_comparison_op", True),
+ ("objspace.std.builtinshortcut", True),
("translation.list_comprehension_operations",True),
],
cmdline="--allopts --faassen", negation=False),
Added: pypy/branch/faster-binop/pypy/doc/config/objspace.std.builtinshortcut.txt
==============================================================================
--- (empty file)
+++ pypy/branch/faster-binop/pypy/doc/config/objspace.std.builtinshortcut.txt Wed Apr 30 17:59:19 2008
@@ -0,0 +1,5 @@
+A shortcut speeding up primitive operations between built-in types.
+
+This is a space-time trade-off: at the moment, this option makes a
+translated pypy-c executable bigger by about 1.7 MB. (This can probably
+be improved with careful analysis.)
Modified: pypy/branch/faster-binop/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/faster-binop/pypy/objspace/std/objspace.py (original)
+++ pypy/branch/faster-binop/pypy/objspace/std/objspace.py Wed Apr 30 17:59:19 2008
@@ -277,12 +277,11 @@
return func_with_new_name(boundmethod, 'boundmethod_'+name)
boundmethod = make_boundmethod()
setattr(self, name, boundmethod) # store into 'space' instance
- else:
- # if config...:
+ elif self.config.objspace.std.builtinshortcut:
from pypy.objspace.std import builtinshortcut
builtinshortcut.install(self, mm)
- if 1: # if config...:
+ if self.config.objspace.std.builtinshortcut:
from pypy.objspace.std import builtinshortcut
builtinshortcut.install_is_true(self, self.MM.nonzero, self.MM.len)
Added: pypy/branch/faster-binop/pypy/objspace/std/test/test_builtinshortcut.py
==============================================================================
--- (empty file)
+++ pypy/branch/faster-binop/pypy/objspace/std/test/test_builtinshortcut.py Wed Apr 30 17:59:19 2008
@@ -0,0 +1,7 @@
+from pypy.objspace.std.test import test_userobject
+
+class AppTestUserObject(test_userobject.AppTestUserObject):
+ OPTIONS = {'objspace.std.builtinshortcut': True}
+
+class AppTestWithMultiMethodVersion2(test_userobject.AppTestWithMultiMethodVersion2):
+ OPTIONS = {'objspace.std.builtinshortcut': True}
Modified: pypy/branch/faster-binop/pypy/objspace/std/test/test_userobject.py
==============================================================================
--- pypy/branch/faster-binop/pypy/objspace/std/test/test_userobject.py (original)
+++ pypy/branch/faster-binop/pypy/objspace/std/test/test_userobject.py Wed Apr 30 17:59:19 2008
@@ -1,6 +1,12 @@
class AppTestUserObject:
+ OPTIONS = {} # for test_builtinshortcut.py
+
+ def setup_class(cls):
+ from pypy import conftest
+ cls.space = conftest.gettestobjspace(**cls.OPTIONS)
+
def test_emptyclass(self):
class empty: pass
inst = empty()
@@ -196,6 +202,7 @@
class AppTestWithMultiMethodVersion2(AppTestUserObject):
+ OPTIONS = {} # for test_builtinshortcut.py
def setup_class(cls):
from pypy import conftest
@@ -203,7 +210,8 @@
cls.prev_installer = multimethod.Installer
multimethod.Installer = multimethod.InstallerVersion2
- cls.space = conftest.maketestobjspace()
+ config = conftest.make_config(conftest.option, **cls.OPTIONS)
+ cls.space = conftest.maketestobjspace(config)
def teardown_class(cls):
from pypy.objspace.std import multimethod
More information about the Pypy-commit
mailing list