Author: Brian Kearns <bdkea...@gmail.com>
Branch: elidable-canfold-exception
Changeset: r70048:ca1d94c202fc
Date: 2014-03-18 04:39 -0400
http://bitbucket.org/pypy/pypy/changeset/ca1d94c202fc/

Log:    cleaner? no need to unpack args ourself

diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -1,5 +1,4 @@
 import sys
-import types
 import warnings
 
 import py
@@ -13,7 +12,7 @@
 DEBUG_ELIDABLE_FUNCTIONS = False
 
 
-def elidable(*args, **kwargs):
+def elidable(canfolderror=None):
     """ Decorate a function as "trace-elidable". Usually this means simply that
     the function is constant-foldable, i.e. is pure and has no side-effects.
 
@@ -38,7 +37,6 @@
     In this case, if it raises specific exception listed there, it's also
     constant folded away.
     """
-
     def decorator(func):
         if DEBUG_ELIDABLE_FUNCTIONS:
             cache = {}
@@ -56,17 +54,17 @@
         if canfolderror is not None:
             func._elidable_exceptions_ = canfolderror
         return func
+    return decorator
 
+_elidable = elidable
+def elidable(*args, **kwargs):
     if len(args) == 1:
-        # non-ported
         assert len(kwargs) == 0
         warnings.warn("@elidable is deprecated, use @elidable() instead", 
stacklevel=2)
-        canfolderror = None
-        return decorator(args[0])
+        return _elidable()(args[0])
     else:
         assert len(args) == 0
-        canfolderror = kwargs.get('canfolderror', None)
-        return decorator
+        return _elidable(**kwargs)
 
 def purefunction(*args, **kwargs):
     import warnings
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to