[pypy-svn] r75913 - pypy/branch/reflex-support/pypy/jit/tl

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Jul 6 16:12:40 CEST 2010


Author: cfbolz
Date: Tue Jul  6 16:12:39 2010
New Revision: 75913

Modified:
   pypy/branch/reflex-support/pypy/jit/tl/pypyjit.py
   pypy/branch/reflex-support/pypy/jit/tl/pypyjit_demo.py
Log:
the code that we would like to make fast with the JIT


Modified: pypy/branch/reflex-support/pypy/jit/tl/pypyjit.py
==============================================================================
--- pypy/branch/reflex-support/pypy/jit/tl/pypyjit.py	(original)
+++ pypy/branch/reflex-support/pypy/jit/tl/pypyjit.py	Tue Jul  6 16:12:39 2010
@@ -39,6 +39,7 @@
 config.objspace.usemodules.pypyjit = True
 config.objspace.usemodules._weakref = False
 config.objspace.usemodules._sre = False
+config.objspace.usemodules.cppyy = True
 set_pypy_opt_level(config, level='jit')
 config.objspace.std.withinlineddict = True
 

Modified: pypy/branch/reflex-support/pypy/jit/tl/pypyjit_demo.py
==============================================================================
--- pypy/branch/reflex-support/pypy/jit/tl/pypyjit_demo.py	(original)
+++ pypy/branch/reflex-support/pypy/jit/tl/pypyjit_demo.py	Tue Jul  6 16:12:39 2010
@@ -1,38 +1,14 @@
-base = object
-
-class Number(base):
-    __slots__ = ('val', )
-    def __init__(self, val=0):
-        self.val = val
-
-    def __add__(self, other):
-        if not isinstance(other, int):
-            other = other.val
-        return Number(val=self.val + other)
-            
-    def __cmp__(self, other):
-        val = self.val
-        if not isinstance(other, int):
-            other = other.val
-        return cmp(val, other)
-
-    def __nonzero__(self):
-        return bool(self.val)
-
-def g(x, inc=2):
-    return x + inc
-
-def f(n, x, inc):
-    while x < n:
-        x = g(x, inc=1)
-    return x
+import cppyy
 
 import time
-#t1 = time.time()
-#f(10000000, Number(), 1)
-#t2 = time.time()
-#print t2 - t1
+import cppyy
+lib = cppyy.load_lib("example01Dict.so")
+cls = lib.type_byname("example01")
+inst = cls.construct(-17)
+
 t1 = time.time()
-f(10000000, 0, 1)
+res = 0
+for i in range(1000000):
+    res += inst.invoke("add", i)
 t2 = time.time()
 print t2 - t1



More information about the Pypy-commit mailing list