[pypy-commit] pypy default: make the path that the JIT cannot see smaller
cfbolz
noreply at buildbot.pypy.org
Mon Apr 16 11:46:21 CEST 2012
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch:
Changeset: r54385:f48f3db6048d
Date: 2012-04-14 09:49 +0200
http://bitbucket.org/pypy/pypy/changeset/f48f3db6048d/
Log: make the path that the JIT cannot see smaller
diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -171,7 +171,13 @@
space = self.space
keywords, values_w = space.view_as_kwargs(w_starstararg)
if keywords is not None: # this path also taken for empty dicts
- self._add_keywordargs_no_unwrapping(keywords, values_w)
+ if self.keywords is None:
+ self.keywords = keywords[:] # copy to make non-resizable
+ self.keywords_w = values_w[:]
+ else:
+ self._check_not_duplicate_kwargs(keywords, values_w)
+ self.keywords = self.keywords + keywords
+ self.keywords_w = self.keywords_w + values_w
return not jit.isconstant(len(self.keywords))
if space.isinstance_w(w_starstararg, space.w_dict):
keys_w = space.unpackiterable(w_starstararg)
@@ -229,22 +235,16 @@
@jit.look_inside_iff(lambda self, keywords, keywords_w:
jit.isconstant(len(keywords) and
jit.isconstant(self.keywords)))
- def _add_keywordargs_no_unwrapping(self, keywords, keywords_w):
- if self.keywords is None:
- self.keywords = keywords[:] # copy to make non-resizable
- self.keywords_w = keywords_w[:]
- else:
- # looks quadratic, but the JIT should remove all of it nicely.
- # Also, all the lists should be small
- for key in keywords:
- for otherkey in self.keywords:
- if otherkey == key:
- raise operationerrfmt(self.space.w_TypeError,
- "got multiple values "
- "for keyword argument "
- "'%s'", key)
- self.keywords = self.keywords + keywords
- self.keywords_w = self.keywords_w + keywords_w
+ def _check_not_duplicate_kwargs(self, keywords, keywords_w):
+ # looks quadratic, but the JIT should remove all of it nicely.
+ # Also, all the lists should be small
+ for key in keywords:
+ for otherkey in self.keywords:
+ if otherkey == key:
+ raise operationerrfmt(self.space.w_TypeError,
+ "got multiple values "
+ "for keyword argument "
+ "'%s'", key)
def fixedunpack(self, argcount):
"""The simplest argument parsing: get the 'argcount' arguments,
More information about the pypy-commit
mailing list