Author: Alex Gaynor <[email protected]>
Branch: unroll-if-alt
Changeset: r46082:db578c6cbc4b
Date: 2011-07-28 21:29 -0700
http://bitbucket.org/pypy/pypy/changeset/db578c6cbc4b/
Log: Use a closure, makes both gutworth and I happy. Also start messing
with pypyjit.
diff --git a/pypy/jit/tl/pypyjit.py b/pypy/jit/tl/pypyjit.py
--- a/pypy/jit/tl/pypyjit.py
+++ b/pypy/jit/tl/pypyjit.py
@@ -37,13 +37,13 @@
set_opt_level(config, level='jit')
config.objspace.allworkingmodules = False
config.objspace.usemodules.pypyjit = True
-config.objspace.usemodules.array = True
+config.objspace.usemodules.array = False
config.objspace.usemodules._weakref = True
config.objspace.usemodules._sre = False
-config.objspace.usemodules._lsprof = True
+config.objspace.usemodules._lsprof = False
#
-config.objspace.usemodules._ffi = True
-config.objspace.usemodules.micronumpy = True
+config.objspace.usemodules._ffi = False
+config.objspace.usemodules.micronumpy = False
#
set_pypy_opt_level(config, level='jit')
diff --git a/pypy/jit/tl/pypyjit_demo.py b/pypy/jit/tl/pypyjit_demo.py
--- a/pypy/jit/tl/pypyjit_demo.py
+++ b/pypy/jit/tl/pypyjit_demo.py
@@ -1,9 +1,7 @@
try:
- import numpy
- a = numpy.array(range(10))
- b = a + a + a
- print b[3]
+ for i in xrange(1000):
+ "%d %d" % (i, i)
except Exception, e:
print "Exception: ", type(e)
diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py
--- a/pypy/rlib/jit.py
+++ b/pypy/rlib/jit.py
@@ -110,23 +110,16 @@
def unroll_if(predicate):
def inner(func):
- args = _get_args(func)
- argstring = ", ".join(args)
- d = {
- "func": func,
- "func_unroll": unroll_safe(func_with_new_name(func, func.__name__
+ "_unroll")),
- "predicate": predicate,
- }
- exec py.code.Source("""
- def f(%(argstring)s):
- if predicate(%(argstring)s):
- return func_unroll(%(argstring)s)
- else:
- return func(%(argstring)s)
- """ % {"argstring": argstring}).compile() in d
- result = d["f"]
- result.func_name = func.func_name + "_unroll_if"
- return result
+ func_unroll = unroll_safe(func_with_new_name(func, func.__name__ +
"_unroll"))
+
+ def f(*args):
+ if predicate(*args):
+ return func_unroll(*args)
+ else:
+ return func(*args)
+
+ f.func_name = func.func_name + "_unroll_if"
+ return f
return inner
def oopspec(spec):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit