Commits

Armin Rigo committed b4acd9a

Revert the introduction of the class Defaults in function.py
(manually, so I hope I didn't forget anything). Replace it
with the single line:

_immutable_fields_ = ['defs?[*]']

Comments (0)

Files changed (14)

pypy/annotation/description.py

 from pypy.interpreter.pycode import cpython_code_signature
 from pypy.interpreter.argument import rawshape
 from pypy.interpreter.argument import ArgErr
-from pypy.interpreter.function import Defaults
 from pypy.tool.sourcetools import valid_identifier
 from pypy.tool.pairtype import extendabletype
 
             for x in defaults:
                 defs_s.append(self.bookkeeper.immutablevalue(x))
         try:
-            inputcells = args.match_signature(signature, Defaults(defs_s))
+            inputcells = args.match_signature(signature, defs_s)
         except ArgErr, e:
             raise TypeError, "signature mismatch: %s" % e.getmsg(self.name)
         return inputcells

pypy/interpreter/argument.py

 
     ###  Parsing for function calls  ###
 
-    def _match_signature(self, w_firstarg, scope_w, signature, defaults=None,
+    def _match_signature(self, w_firstarg, scope_w, signature, defaults_w=None,
                          blindargs=0):
         """Parse args and kwargs according to the signature of a code object,
         or raise an ArgErr in case of failure.
         """
         if jit.we_are_jitted() and self._dont_jit:
             return self._match_signature_jit_opaque(w_firstarg, scope_w,
-                                                    signature, defaults,
+                                                    signature, defaults_w,
                                                     blindargs)
         return self._really_match_signature(w_firstarg, scope_w, signature,
-                                            defaults, blindargs)
+                                            defaults_w, blindargs)
 
     @jit.dont_look_inside
     def _match_signature_jit_opaque(self, w_firstarg, scope_w, signature,
-                                    defaults, blindargs):
+                                    defaults_w, blindargs):
         return self._really_match_signature(w_firstarg, scope_w, signature,
-                                            defaults, blindargs)
+                                            defaults_w, blindargs)
 
     @jit.unroll_safe
-    def _really_match_signature(self, w_firstarg, scope_w, signature, defaults=None,
-                                blindargs=0):
+    def _really_match_signature(self, w_firstarg, scope_w, signature,
+                                defaults_w=None, blindargs=0):
         #
         #   args_w = list of the normal actual parameters, wrapped
         #   kwds_w = real dictionary {'keyword': wrapped parameter}
         elif avail > co_argcount:
             raise ArgErrCount(avail, num_kwds,
                               co_argcount, has_vararg, has_kwarg,
-                              defaults, 0)
+                              defaults_w, 0)
 
         # the code assumes that keywords can potentially be large, but that
         # argnames is typically not too large
                     num_remainingkwds -= 1
         missing = 0
         if input_argcount < co_argcount:
-            def_first = co_argcount - (0 if defaults is None else defaults.getlen())
+            def_first = co_argcount - (0 if defaults_w is None else len(defaults_w))
             for i in range(input_argcount, co_argcount):
                 if scope_w[i] is not None:
-                    pass
-                elif i >= def_first:
-                    scope_w[i] = defaults.getitem(i - def_first)
+                    continue
+                defnum = i - def_first
+                if defnum >= 0:
+                    scope_w[i] = defaults_w[defnum]
                 else:
                     # error: not enough arguments.  Don't signal it immediately
                     # because it might be related to a problem with */** or
             if co_argcount == 0:
                 raise ArgErrCount(avail, num_kwds,
                               co_argcount, has_vararg, has_kwarg,
-                              defaults, missing)
+                              defaults_w, missing)
             raise ArgErrUnknownKwds(num_remainingkwds, keywords, used_keywords)
 
         if missing:
             raise ArgErrCount(avail, num_kwds,
                               co_argcount, has_vararg, has_kwarg,
-                              defaults, missing)
+                              defaults_w, missing)
 
         return co_argcount + has_vararg + has_kwarg
 
 
 
     def parse_into_scope(self, w_firstarg,
-                         scope_w, fnname, signature, defaults=None):
+                         scope_w, fnname, signature, defaults_w=None):
         """Parse args and kwargs to initialize a frame
         according to the signature of code object.
         Store the argumentvalues into scope_w.
         """
         try:
             return self._match_signature(w_firstarg,
-                                         scope_w, signature, defaults, 0)
+                                         scope_w, signature, defaults_w, 0)
         except ArgErr, e:
             raise OperationError(self.space.w_TypeError,
                                  self.space.wrap(e.getmsg(fnname)))
 
-    def _parse(self, w_firstarg, signature, defaults, blindargs=0):
+    def _parse(self, w_firstarg, signature, defaults_w, blindargs=0):
         """Parse args and kwargs according to the signature of a code object,
         or raise an ArgErr in case of failure.
         """
         scopelen = signature.scope_length()
         scope_w = [None] * scopelen
-        self._match_signature(w_firstarg, scope_w, signature, defaults,
+        self._match_signature(w_firstarg, scope_w, signature, defaults_w,
                               blindargs)
         return scope_w
 
 
     def parse_obj(self, w_firstarg,
-                  fnname, signature, defaults=None, blindargs=0):
+                  fnname, signature, defaults_w=None, blindargs=0):
         """Parse args and kwargs to initialize a frame
         according to the signature of code object.
         """
         try:
-            return self._parse(w_firstarg, signature, defaults, blindargs)
+            return self._parse(w_firstarg, signature, defaults_w, blindargs)
         except ArgErr, e:
             raise OperationError(self.space.w_TypeError,
                                  self.space.wrap(e.getmsg(fnname)))
 
 
 
-    def _match_signature(self, w_firstarg, scope_w, signature, defaults=None,
+    def _match_signature(self, w_firstarg, scope_w, signature, defaults_w=None,
                          blindargs=0):
         self.combine_if_necessary()
         # _match_signature is destructive
         return Arguments._match_signature(
                self, w_firstarg, scope_w, signature,
-               defaults, blindargs)
+               defaults_w, blindargs)
 
     def unpack(self):
         self.combine_if_necessary()
         return Arguments.unpack(self)
 
-    def match_signature(self, signature, defaults):
+    def match_signature(self, signature, defaults_w):
         """Parse args and kwargs according to the signature of a code object,
         or raise an ArgErr in case of failure.
         """
-        return self._parse(None, signature, defaults)
+        return self._parse(None, signature, defaults_w)
 
     def unmatch_signature(self, signature, data_w):
         """kind of inverse of match_signature"""
 class ArgErrCount(ArgErr):
 
     def __init__(self, got_nargs, nkwds, expected_nargs, has_vararg, has_kwarg,
-                 defaults, missing_args):
+                 defaults_w, missing_args):
         self.expected_nargs = expected_nargs
         self.has_vararg = has_vararg
         self.has_kwarg = has_kwarg
 
-        self.num_defaults = 0 if defaults is None else defaults.getlen()
+        self.num_defaults = 0 if defaults_w is None else len(defaults_w)
         self.missing_args = missing_args
         self.num_args = got_nargs
         self.num_kwds = nkwds

pypy/interpreter/function.py

     assert not func.can_change_code
     return func.code
 
-class Defaults(object):
-    _immutable_fields_ = ["items[*]", "promote"]
-
-    def __init__(self, items, promote=False):
-        self.items = items
-        self.promote = promote
-
-    def getitems(self):
-        # an idea - we want to promote only items that we know won't change
-        # too often. this is the case for builtin functions and functions
-        # with known constant defaults. Otherwise we don't want to promote
-        # this so lambda a=a won't create a new trace each time it's
-        # encountered
-        if self.promote:
-            return jit.hint(self, promote=True).items
-        return self.items
-
-    def getitem(self, idx):
-        return self.getitems()[idx]
-
-    def getlen(self):
-        return len(self.getitems())
 
 class Function(Wrappable):
     """A function is a code object captured with some environment:
     and an arbitrary 'closure' passed to the code object."""
 
     can_change_code = True
+    _immutable_fields_ = ['defs?[*]']
 
     def __init__(self, space, code, w_globals=None, defs_w=[], closure=None,
-                 forcename=None, promote_defs=False):
+                 forcename=None):
         self.space = space
         self.name = forcename or code.co_name
         self.w_doc = None   # lazily read from code.getdocstring()
         self.code = code       # Code instance
         self.w_func_globals = w_globals  # the globals dictionary
         self.closure   = closure    # normally, list of Cell instances or None
-        self.defs = Defaults(defs_w, promote=promote_defs)
-        # wrapper around list of w_default's
+        self.defs_w = defs_w
         self.w_func_dict = None # filled out below if needed
         self.w_module = None
 
             return self._flat_pycall(code, nargs, frame)
         elif fast_natural_arity & Code.FLATPYCALL:
             natural_arity = fast_natural_arity & 0xff
-            if natural_arity > nargs >= natural_arity - self.defs.getlen():
+            if natural_arity > nargs >= natural_arity - len(self.defs_w):
                 assert isinstance(code, PyCode)
                 return self._flat_pycall_defaults(code, nargs, frame,
                                                   natural_arity - nargs)
             w_arg = frame.peekvalue(nargs-1-i)
             new_frame.fastlocals_w[i] = w_arg
 
-        defs = self.defs
-        ndefs = defs.getlen()
+        ndefs = len(self.defs_w)
         start = ndefs - defs_to_load
         i = nargs
         for j in xrange(start, ndefs):
-            new_frame.fastlocals_w[i] = defs.getitem(j)
+            new_frame.fastlocals_w[i] = self.defs_w[j]
             i += 1
         return new_frame.run()
 
             w(self.code),
             w_func_globals,
             w_closure,
-            nt(self.defs.getitems()),
+            nt(self.defs_w),
             w_func_dict,
             self.w_module,
         ]
         if space.is_w(w_func_dict, space.w_None):
             w_func_dict = None
         self.w_func_dict = w_func_dict
-        self.defs = Defaults(space.fixedview(w_defs))
+        self.defs_w = space.fixedview(w_defs)
         self.w_module = w_module
 
     def fget_func_defaults(self, space):
-        values_w = self.defs.getitems()
+        values_w = self.defs_w
         # the `None in values_w` check here is to ensure that interp-level
         # functions with a default of NoneNotWrapped do not get their defaults
         # exposed at applevel
 
     def fset_func_defaults(self, space, w_defaults):
         if space.is_w(w_defaults, space.w_None):
-            self.defs = Defaults([])
+            self.defs_w = []
             return
         if not space.is_true(space.isinstance(w_defaults, space.w_tuple)):
             raise OperationError( space.w_TypeError, space.wrap("func_defaults must be set to a tuple object or None") )
-        self.defs = Defaults(space.fixedview(w_defaults))
+        self.defs_w = space.fixedview(w_defaults)
 
     def fdel_func_defaults(self, space):
-        self.defs = Defaults([])
+        self.defs_w = []
 
     def fget_func_doc(self, space):
         if self.w_doc is None:
     def __init__(self, func):
         assert isinstance(func, Function)
         Function.__init__(self, func.space, func.code, func.w_func_globals,
-                          func.defs.getitems(), func.closure, func.name,
-                          promote_defs=True)
+                          func.defs_w, func.closure, func.name)
         self.w_doc = func.w_doc
         self.w_func_dict = func.w_func_dict
         self.w_module = func.w_module

pypy/interpreter/gateway.py

         space = func.space
         activation = self.activation
         scope_w = args.parse_obj(w_obj, func.name, self.sig,
-                                 func.defs, self.minargs)
+                                 func.defs_w, self.minargs)
         try:
             w_result = activation._run(space, scope_w)
         except DescrMismatch:

pypy/interpreter/pycode.py

                                       fresh_virtualizable=True)
         args_matched = args.parse_into_scope(None, fresh_frame.fastlocals_w,
                                              func.name,
-                                             sig, func.defs)
+                                             sig, func.defs_w)
         fresh_frame.init_cells()
         return frame.run()
 
                                       fresh_virtualizable=True)
         args_matched = args.parse_into_scope(w_obj, fresh_frame.fastlocals_w,
                                              func.name,
-                                             sig, func.defs)
+                                             sig, func.defs_w)
         fresh_frame.init_cells()
         return frame.run()
 

pypy/interpreter/test/test_argument.py

     ArgErr, ArgErrUnknownKwds, ArgErrMultipleValues, ArgErrCount, rawshape,
     Signature)
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.function import Defaults
 
 
 class TestSignature(object):
         py.test.raises(ArgErr, args._match_signature, None, l, Signature(["a"], "*"))
         args = Arguments(space, [])
         l = [None]
-        args._match_signature(None, l, Signature(["a"]), defaults=Defaults([1]))
+        args._match_signature(None, l, Signature(["a"]), defaults_w=[1])
         assert l == [1]
         args = Arguments(space, [])
         l = [None]
                 py.test.raises(ArgErr, args._match_signature, firstarg, l, Signature(["a", "b", "c", "d", "e"], "*"))
                 l = [None, None, None, None, None]
                 args = Arguments(space, arglist, w_stararg=starargs)
-                args._match_signature(firstarg, l, Signature(["a", "b", "c", "d", "e"]), defaults=Defaults([1]))
+                args._match_signature(firstarg, l, Signature(["a", "b", "c", "d", "e"]), defaults_w=[1])
                 assert l == [4, 5, 6, 7, 1]
                 for j in range(len(values)):
                     l = [None] * (j + 1)
             assert len(keywords) == len(keywords_w)
             args = Arguments(space, [1, 2], keywords[:], keywords_w[:], w_starstararg=w_kwds)
             l = [None, None, None]
-            args._match_signature(None, l, Signature(["a", "b", "c"]), defaults=Defaults([4]))
+            args._match_signature(None, l, Signature(["a", "b", "c"]), defaults_w=[4])
             assert l == [1, 2, 3]
             args = Arguments(space, [1, 2], keywords[:], keywords_w[:], w_starstararg=w_kwds)
             l = [None, None, None, None]
-            args._match_signature(None, l, Signature(["a", "b", "b1", "c"]), defaults=Defaults([4, 5]))
+            args._match_signature(None, l, Signature(["a", "b", "b1", "c"]), defaults_w=[4, 5])
             assert l == [1, 2, 4, 3]
             args = Arguments(space, [1, 2], keywords[:], keywords_w[:], w_starstararg=w_kwds)
             l = [None, None, None, None]
-            args._match_signature(None, l, Signature(["a", "b", "c", "d"]), defaults=Defaults([4, 5]))
+            args._match_signature(None, l, Signature(["a", "b", "c", "d"]), defaults_w=[4, 5])
             assert l == [1, 2, 3, 5]
             args = Arguments(space, [1, 2], keywords[:], keywords_w[:], w_starstararg=w_kwds)
             l = [None, None, None, None]
             py.test.raises(ArgErr, args._match_signature, None, l,
-                           Signature(["c", "b", "a", "d"]), defaults=Defaults([4, 5]))
+                           Signature(["c", "b", "a", "d"]), defaults_w=[4, 5])
             args = Arguments(space, [1, 2], keywords[:], keywords_w[:], w_starstararg=w_kwds)
             l = [None, None, None, None]
             py.test.raises(ArgErr, args._match_signature, None, l,
-                           Signature(["a", "b", "c1", "d"]), defaults=Defaults([4, 5]))
+                           Signature(["a", "b", "c1", "d"]), defaults_w=[4, 5])
             args = Arguments(space, [1, 2], keywords[:], keywords_w[:], w_starstararg=w_kwds)
             l = [None, None, None]
             args._match_signature(None, l, Signature(["a", "b"], None, "**"))
         calls = []
 
         def _match_signature(w_firstarg, scope_w, signature,
-                             defaults=None, blindargs=0):
-            defaults = [] if defaults is None else defaults.getitems()
+                             defaults_w=None, blindargs=0):
+            defaults_w = [] if defaults_w is None else defaults_w
             calls.append((w_firstarg, scope_w, signature.argnames, signature.has_vararg(),
-                          signature.has_kwarg(), defaults, blindargs))
+                          signature.has_kwarg(), defaults_w, blindargs))
         args._match_signature = _match_signature
 
         scope_w = args.parse_obj(None, "foo", Signature(["a", "b"], None, None))
         calls = []
 
         scope_w = args.parse_obj(None, "foo", Signature(["a", "b"], "args", "kw"),
-                             defaults=Defaults(['x', 'y']))
+                             defaults_w=['x', 'y'])
         assert len(calls) == 1
         assert calls[0] == (None, [None, None, None, None], ["a", "b"],
                             True, True,
         calls = []
 
         scope_w = args.parse_obj("obj", "foo", Signature(["a", "b"], "args", "kw"),
-                             defaults=Defaults(['x', 'y']), blindargs=1)
+                             defaults_w=['x', 'y'], blindargs=1)
         assert len(calls) == 1
         assert calls[0] == ("obj", [None, None, None, None], ["a", "b"],
                             True, True,
         calls = []
 
         def _match_signature(w_firstarg, scope_w, signature,
-                             defaults=None, blindargs=0):
-            defaults = [] if defaults is None else defaults.getitems()
+                             defaults_w=None, blindargs=0):
+            defaults_w = [] if defaults_w is None else defaults_w
             calls.append((w_firstarg, scope_w, signature.argnames, signature.has_vararg(),
-                          signature.has_kwarg(), defaults, blindargs))
+                          signature.has_kwarg(), defaults_w, blindargs))
         args._match_signature = _match_signature
 
         scope_w = [None, None]
 
         scope_w = [None, None, None, None]
         args.parse_into_scope(None, scope_w, "foo", Signature(["a", "b"], "args", "kw"),
-                              defaults=Defaults(['x', 'y']))
+                              defaults_w=['x', 'y'])
         assert len(calls) == 1
         assert calls[0] == (None, scope_w, ["a", "b"],
                             True, True,
         scope_w = [None, None, None, None]
         args.parse_into_scope("obj", scope_w, "foo", Signature(["a", "b"],
                                                       "args", "kw"),
-                              defaults=Defaults(['x', 'y']))
+                              defaults_w=['x', 'y'])
         assert len(calls) == 1
         assert calls[0] == ("obj", scope_w, ["a", "b"],
                             True, True,
     def test_missing_args(self):
         # got_nargs, nkwds, expected_nargs, has_vararg, has_kwarg,
         # defaults_w, missing_args
-        err = ArgErrCount(1, 0, 0, False, False, Defaults([]), 0)
+        err = ArgErrCount(1, 0, 0, False, False, None, 0)
         s = err.getmsg('foo')
         assert s == "foo() takes no argument (1 given)"
-        err = ArgErrCount(0, 0, 1, False, False, Defaults([]), 1)
+        err = ArgErrCount(0, 0, 1, False, False, [], 1)
         s = err.getmsg('foo')
         assert s == "foo() takes exactly 1 argument (0 given)"
-        err = ArgErrCount(3, 0, 2, False, False, Defaults([]), 0)
+        err = ArgErrCount(3, 0, 2, False, False, [], 0)
         s = err.getmsg('foo')
         assert s == "foo() takes exactly 2 arguments (3 given)"
-        err = ArgErrCount(1, 0, 2, True, False, Defaults([]), 1)
+        err = ArgErrCount(1, 0, 2, True, False, [], 1)
         s = err.getmsg('foo')
         assert s == "foo() takes at least 2 arguments (1 given)"
-        err = ArgErrCount(3, 0, 2, True, False, Defaults(['a']), 0)
+        err = ArgErrCount(3, 0, 2, True, False, ['a'], 0)
         s = err.getmsg('foo')
         assert s == "foo() takes at most 2 arguments (3 given)"
-        err = ArgErrCount(0, 1, 2, True, False, Defaults(['a']), 1)
+        err = ArgErrCount(0, 1, 2, True, False, ['a'], 1)
         s = err.getmsg('foo')
         assert s == "foo() takes at least 1 argument (1 given)"
-        err = ArgErrCount(2, 1, 1, False, True, Defaults([]), 0)
+        err = ArgErrCount(2, 1, 1, False, True, [], 0)
         s = err.getmsg('foo')
         assert s == "foo() takes exactly 1 argument (3 given)"
 
 
         args = make_arguments_for_translation(space, [1])
         sig = Signature(['a', 'b', 'c'], None, None)
-        data = args.match_signature(sig, Defaults([2, 3]))
+        data = args.match_signature(sig, [2, 3])
         new_args = args.unmatch_signature(sig, data)
         assert args.unpack() == new_args.unpack()
 
 
         args = make_arguments_for_translation(space, [1], {'c': 3, 'b': 2})
         sig = Signature(['a', 'b', 'c'], None, None)
-        data = args.match_signature(sig, Defaults([]))
+        data = args.match_signature(sig, [])
         new_args = args.unmatch_signature(sig, data)
         assert args.unpack() == new_args.unpack()
 
         args = make_arguments_for_translation(space, [1], {'c': 5})
         sig = Signature(['a', 'b', 'c'], None, None)
-        data = args.match_signature(sig, Defaults([2, 3]))
+        data = args.match_signature(sig, [2, 3])
         new_args = args.unmatch_signature(sig, data)
         assert args.unpack() == new_args.unpack()
 
         args = make_arguments_for_translation(space, [1], {'c': 5, 'd': 7})
         sig = Signature(['a', 'b', 'c'], None, 'kw')
-        data = args.match_signature(sig, Defaults([2, 3]))
+        data = args.match_signature(sig, [2, 3])
         new_args = args.unmatch_signature(sig, data)
         assert args.unpack() == new_args.unpack()
 
         args = make_arguments_for_translation(space, [1,2,3,4,5], {'e': 5, 'd': 7})
         sig = Signature(['a', 'b', 'c'], 'r', 'kw')
-        data = args.match_signature(sig, Defaults([2, 3]))
+        data = args.match_signature(sig, [2, 3])
         new_args = args.unmatch_signature(sig, data)
         assert args.unpack() == new_args.unpack()
 
                                        w_stararg=[1],
                                        w_starstararg={'c': 5, 'd': 7})
         sig = Signature(['a', 'b', 'c'], None, 'kw')
-        data = args.match_signature(sig, Defaults([2, 3]))
+        data = args.match_signature(sig, [2, 3])
         new_args = args.unmatch_signature(sig, data)
         assert args.unpack() == new_args.unpack()
 
                                        w_stararg=[3,4,5],
                                        w_starstararg={'e': 5, 'd': 7})
         sig = Signature(['a', 'b', 'c'], 'r', 'kw')
-        data = args.match_signature(sig, Defaults([2, 3]))
+        data = args.match_signature(sig, [2, 3])
         new_args = args.unmatch_signature(sig, data)
         assert args.unpack() == new_args.unpack()
 

pypy/interpreter/test/test_gateway.py

 from pypy.conftest import gettestobjspace
 from pypy.interpreter import gateway, argument
 from pypy.interpreter.gateway import ObjSpace, W_Root
-from pypy.interpreter.function import Defaults
 import py
 import sys
 
     def __init__(self, space, name):
         self.space = space
         self.name = name
-        self.defs = Defaults([])
+        self.defs_w = []
 
 class TestBuiltinCode:
     def test_signature(self):

pypy/objspace/std/bytearrayobject.py

 from pypy.interpreter import gateway
 from pypy.interpreter.argument import Signature
 from pypy.interpreter.buffer import RWBuffer
-from pypy.interpreter.function import Defaults
 from pypy.objspace.std.bytearraytype import (
     makebytearraydata_w, getbytevalue,
     new_bytearray
 registerimplementation(W_BytearrayObject)
 
 init_signature = Signature(['source', 'encoding', 'errors'], None, None)
-init_defaults = Defaults([None, None, None])
+init_defaults = [None, None, None]
 
 def init__Bytearray(space, w_bytearray, __args__):
     # this is on the silly side

pypy/objspace/std/dictmultiobject.py

 from pypy.interpreter import gateway
 from pypy.interpreter.argument import Signature
 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.function import Defaults
 from pypy.module.__builtin__.__init__ import BUILTIN_TO_INDEX, OPTIMIZED_BUILTINS
 
 from pypy.rlib.objectmodel import r_dict, we_are_translated
 
 
 init_signature = Signature(['seq_or_map'], None, 'kwargs')
-init_defaults = Defaults([None])
+init_defaults = [None]
 
 def update1(space, w_dict, w_data):
     if space.findattr(w_data, space.wrap("keys")) is None:

pypy/objspace/std/fake.py

         frame = func.space.createframe(self, func.w_func_globals,
                                         func.closure)
         sig = self.signature()
-        scope_w = args.parse_obj(None, func.name, sig, func.defs.getitems())
+        scope_w = args.parse_obj(None, func.name, sig, func.defs_w)
         frame.setfastscope(scope_w)
         return frame.run()
 

pypy/objspace/std/listobject.py

 
 from pypy.objspace.std import slicetype
 from pypy.interpreter import gateway, baseobjspace
-from pypy.interpreter.function import Defaults
 from pypy.rlib.listsort import TimSort
 from pypy.interpreter.argument import Signature
 
 
 
 init_signature = Signature(['sequence'], None, None)
-init_defaults = Defaults([None])
+init_defaults = [None]
 
 def init__List(space, w_list, __args__):
     from pypy.objspace.std.tupleobject import W_TupleObject

pypy/objspace/std/setobject.py

 from pypy.interpreter.error import OperationError
 from pypy.interpreter import gateway
 from pypy.interpreter.argument import Signature
-from pypy.interpreter.function import Defaults
 from pypy.objspace.std.settype import set_typedef as settypedef
 from pypy.objspace.std.frozensettype import frozenset_typedef as frozensettypedef
 
 cmp__Frozenset_frozensettypedef = cmp__Set_settypedef
 
 init_signature = Signature(['some_iterable'], None, None)
-init_defaults = Defaults([None])
+init_defaults = [None]
 def init__Set(space, w_set, __args__):
     w_iterable, = __args__.parse_obj(
             None, 'set',

pypy/rpython/callparse.py

 from pypy.interpreter.argument import ArgumentsForTranslation, ArgErr
-from pypy.interpreter.function import Defaults
 from pypy.annotation import model as annmodel
 from pypy.rpython import rtuple
 from pypy.rpython.error import TyperError
         for x in graph.defaults:
             defs_h.append(ConstHolder(x))
     try:
-        holders = arguments.match_signature(signature, Defaults(defs_h))
+        holders = arguments.match_signature(signature, defs_h)
     except ArgErr, e:
         raise TyperError, "signature mismatch: %s" % e.getmsg(graph.name)
 

pypy/translator/geninterplevel.py

 log = py.log.Producer("geninterp")
 py.log.setconsumer("geninterp", ansi_log)
 
-GI_VERSION = '1.2.8'  # bump this for substantial changes
+GI_VERSION = '1.2.9'  # bump this for substantial changes
 # ____________________________________________________________
 
 try:
             pass
         defaultsname = self.uniquename('default')
         self._defaults_cache[key] = defaultsname
-        self.initcode.append("from pypy.interpreter.function import Defaults")
-        self.initcode.append("%s = Defaults([%s])" % (defaultsname, ', '.join(names)))
+        self.initcode.append("%s = [%s]" % (defaultsname, ', '.join(names)))
         return defaultsname
 
     def gen_rpyfunction(self, func):