Author: Ronan Lamy <ronan.l...@gmail.com> Branch: wrap-specialisation Changeset: r80964:f577010b0f69 Date: 2015-11-25 18:33 +0000 http://bitbucket.org/pypy/pypy/changeset/f577010b0f69/
Log: Just use @specialize.argtype on space.wrap(), instead of having a complicated special case diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py --- a/pypy/objspace/std/objspace.py +++ b/pypy/objspace/std/objspace.py @@ -130,6 +130,7 @@ def wrapbytes(self, x): return wrapstr(self, x) + @specialize.argtype(1) def wrap(self, x): "Wraps the Python value 'x' into one of the wrapper classes." # You might notice that this function is rather conspicuously @@ -172,7 +173,6 @@ else: return W_LongObject.fromrarith_int(x) return self._wrap_not_rpython(x) - wrap._annspecialcase_ = "specialize:wrap" def _wrap_not_rpython(self, x): "NOT_RPYTHON" diff --git a/pypy/tool/ann_override.py b/pypy/tool/ann_override.py --- a/pypy/tool/ann_override.py +++ b/pypy/tool/ann_override.py @@ -1,9 +1,7 @@ # overrides for annotation specific to PyPy codebase from rpython.annotator.policy import AnnotatorPolicy from rpython.flowspace.model import Constant -from rpython.annotator import specialize -from rpython.annotator.classdesc import InstanceSource, ClassDef - +from rpython.annotator.classdesc import InstanceSource def isidentifier(s): @@ -19,37 +17,6 @@ self.lookups_where = {} self.pypytypes = {} - def specialize__wrap(self, funcdesc, args_s): - from pypy.interpreter.baseobjspace import W_Root - W_Root_def = funcdesc.bookkeeper.getuniqueclassdef(W_Root) - typ = args_s[1].knowntype - if isinstance(typ, ClassDef): - assert typ.issubclass(W_Root_def) - typ = W_Root - else: - assert not issubclass(typ, W_Root) - assert typ != tuple, "space.wrap(tuple) forbidden; use newtuple()" - assert typ != list, "space.wrap(list) forbidden; use newlist()" - assert typ != dict, "space.wrap(dict) forbidden; use newdict()" - assert typ != object, "degenerated space.wrap(object)" - if args_s[0].is_constant() and args_s[1].is_constant(): - if typ in (str, bool, int, float): - space = args_s[0].const - x = args_s[1].const - - def fold(): - if typ is str and isidentifier(x): - return space.new_interned_str(x) - else: - return space.wrap(x) - builder = specialize.make_constgraphbuilder(2, factory=fold, - srcmodule='<ann_override.wrap>') - return funcdesc.cachedgraph((typ, x), builder=builder) - if typ is str: - if args_s[1].can_be_None: - typ = (None, str) - return funcdesc.cachedgraph(typ) - def consider_lookup(self, bookkeeper, attr): assert attr not in self.lookups from pypy.objspace.std import typeobject _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit