[pypy-svn] commit/pypy: arigo: "Subtle" rewrite of this logic to not disable the JIT when calling a function

Bitbucket commits-noreply at bitbucket.org
Mon Dec 20 15:02:45 CET 2010


1 new changeset in pypy:

http://bitbucket.org/pypy/pypy/changeset/69b14c60e2b1/
changeset:   r40145:69b14c60e2b1
user:        arigo
date:        2010-12-20 15:01:57
summary:     "Subtle" rewrite of this logic to not disable the JIT when calling a function
with f(**kwds) where kwds is actually an empty dictionary.
affected #:  1 file (224 bytes)

--- a/pypy/interpreter/argument.py	Mon Dec 20 13:44:14 2010 +0100
+++ b/pypy/interpreter/argument.py	Mon Dec 20 15:01:57 2010 +0100
@@ -105,14 +105,11 @@
         make_sure_not_resized(self.arguments_w)
         if w_stararg is not None:
             self._combine_starargs_wrapped(w_stararg)
-        if w_starstararg is not None:
-            self._combine_starstarargs_wrapped(w_starstararg)
-            # if we have a call where **args are used at the callsite
-            # we shouldn't let the JIT see the argument matching
-            self._dont_jit = True
-        else:
-            self._dont_jit = False
-        
+        # if we have a call where **args are used at the callsite
+        # we shouldn't let the JIT see the argument matching
+        self._dont_jit = (w_starstararg is not None and
+                          self._combine_starstarargs_wrapped(w_starstararg))
+
     def __repr__(self):
         """ NOT_RPYTHON """
         name = self.__class__.__name__
@@ -160,10 +157,20 @@
             raise OperationError(space.w_TypeError,
                                  space.wrap("argument after ** must be "
                                             "a dictionary"))
-        keywords_w = [None] * space.int_w(space.len(w_starstararg))
-        keywords = [None] * space.int_w(space.len(w_starstararg))
+        if space.is_true(w_starstararg):
+            self._do_combine_starstarargs_wrapped(w_starstararg)
+            return True
+        else:
+            return False    # empty dict; don't disable the JIT
+
+    def _do_combine_starstarargs_wrapped(self, w_starstararg):
+        space = self.space
+        keys_w = space.unpackiterable(w_starstararg)
+        length = len(keys_w)
+        keywords_w = [None] * length
+        keywords = [None] * length
         i = 0
-        for w_key in space.unpackiterable(w_starstararg):
+        for w_key in keys_w:
             try:
                 key = space.str_w(w_key)
             except OperationError, e:

Repository URL: https://bitbucket.org/pypy/pypy/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the Pypy-commit mailing list