[pypy-svn] pypy improve-unwrap_spec: More progress

amauryfa commits-noreply at bitbucket.org
Wed Feb 16 19:19:26 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: improve-unwrap_spec
Changeset: r42059:1ac8b35e03d0
Date: 2011-02-16 12:05 +0100
http://bitbucket.org/pypy/pypy/changeset/1ac8b35e03d0/

Log:	More progress

diff --git a/pypy/module/_lsprof/interp_lsprof.py b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -1,9 +1,8 @@
 
-from pypy.interpreter.baseobjspace import (W_Root, ObjSpace, Wrappable,
-                                           Arguments)
+from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.typedef import (TypeDef, GetSetProperty,
                                       interp_attrproperty)
-from pypy.interpreter.gateway import interp2app, NoneNotWrapped
+from pypy.interpreter.gateway import interp2app, unwrap_spec, NoneNotWrapped
 from pypy.interpreter.function import Method, Function
 from pypy.interpreter.error import OperationError
 import time, sys
@@ -30,7 +29,6 @@
         return space.wrap('("%s", %d, %d, %f, %f, %s)' % (
             frame_repr, self.callcount, self.reccallcount,
             self.tt, self.it, calls_repr))
-    repr.unwrap_spec = ['self', ObjSpace]
 
     def get_code(space, self):
         return self.frame
@@ -58,7 +56,6 @@
         frame_repr = space.str_w(space.repr(self.frame))
         return space.wrap('("%s", %d, %d, %f, %f)' % (
             frame_repr, self.callcount, self.reccallcount, self.tt, self.it))
-    repr.unwrap_spec = ['self', ObjSpace]
 
     def get_code(space, self):
         return self.frame
@@ -241,7 +238,6 @@
             self.builtins = space.bool_w(w_builtins)
         # set profiler hook
         space.getexecutioncontext().setllprofile(lsprof_call, space.wrap(self))
-    enable.unwrap_spec = ['self', ObjSpace, W_Root, W_Root]
 
     def _enter_call(self, f_code):
         # we have a superb gc, no point in freelist :)
@@ -295,7 +291,6 @@
         # unset profiler hook
         space.getexecutioncontext().setllprofile(None, None)
         self._flush_unmatched()
-    disable.unwrap_spec = ['self', ObjSpace]
 
     def getstats(self, space):
         if self.w_callable is None:
@@ -306,14 +301,13 @@
             factor = 1.0 / sys.maxint
         return stats(space, self.data.values() + self.builtin_data.values(),
                      factor)
-    getstats.unwrap_spec = ['self', ObjSpace]
 
+ at unwrap_spec(time_unit=float, subcalls=bool, builtins=bool)
 def descr_new_profile(space, w_type, w_callable=NoneNotWrapped, time_unit=0.0,
                       subcalls=True, builtins=True):
     p = space.allocate_instance(W_Profiler, w_type)
     p.__init__(space, w_callable, time_unit, subcalls, builtins)
     return space.wrap(p)
-descr_new_profile.unwrap_spec = [ObjSpace, W_Root, W_Root, float, bool, bool]
 
 W_Profiler.typedef = TypeDef(
     'Profiler',

diff --git a/pypy/module/gc/interp_gc.py b/pypy/module/gc/interp_gc.py
--- a/pypy/module/gc/interp_gc.py
+++ b/pypy/module/gc/interp_gc.py
@@ -1,4 +1,4 @@
-from pypy.interpreter.gateway import ObjSpace
+from pypy.interpreter.gateway import unwrap_spec
 from pypy.interpreter.error import OperationError
 from pypy.rlib import rgc
 from pypy.rlib.streamio import open_file_as_stream
@@ -16,8 +16,6 @@
             cache.clear()
     rgc.collect()
     return space.wrap(0)
-    
-collect.unwrap_spec = [ObjSpace]
 
 def enable_finalizers(space):
     if space.user_del_action.finalizers_lock_count == 0:
@@ -25,14 +23,13 @@
                              space.wrap("finalizers are already enabled"))
     space.user_del_action.finalizers_lock_count -= 1
     space.user_del_action.fire()
-enable_finalizers.unwrap_spec = [ObjSpace]
 
 def disable_finalizers(space):
     space.user_del_action.finalizers_lock_count += 1
-disable_finalizers.unwrap_spec = [ObjSpace]
 
 # ____________________________________________________________
 
+ at unwrap_spec(filename=str)
 def dump_heap_stats(space, filename):
     tb = rgc._heap_stats()
     if not tb:
@@ -43,4 +40,3 @@
         f.write("%d %d " % (tb[i].count, tb[i].size))
         f.write(",".join([str(tb[i].links[j]) for j in range(len(tb))]) + "\n")
     f.close()
-dump_heap_stats.unwrap_spec = [ObjSpace, str]

diff --git a/pypy/module/gc/referents.py b/pypy/module/gc/referents.py
--- a/pypy/module/gc/referents.py
+++ b/pypy/module/gc/referents.py
@@ -1,7 +1,7 @@
 from pypy.rlib import rgc
 from pypy.interpreter.baseobjspace import W_Root, Wrappable
 from pypy.interpreter.typedef import TypeDef
-from pypy.interpreter.gateway import ObjSpace
+from pypy.interpreter.gateway import unwrap_spec
 from pypy.interpreter.error import wrap_oserror, OperationError
 from pypy.rlib.objectmodel import we_are_translated
 
@@ -140,7 +140,6 @@
         gcref = rgc.cast_instance_to_gcref(w_obj)
         _list_w_obj_referents(gcref, result)
     return space.newlist(result)
-get_referents.unwrap_spec = [ObjSpace, 'args_w']
 
 def get_referrers(space, args_w):
     """Return the list of objects that directly refer to any of objs."""
@@ -167,8 +166,8 @@
                         result_w[w_obj] = None
                 pending_w += referents_w
     return space.newlist(result_w.keys())
-get_referrers.unwrap_spec = [ObjSpace, 'args_w']
 
+ at unwrap_spec(fd=int)
 def _dump_rpy_heap(space, fd):
     try:
         ok = rgc.dump_rpy_heap(fd)
@@ -176,10 +175,8 @@
         raise wrap_oserror(space, e)
     if not ok:
         raise missing_operation(space)
-_dump_rpy_heap.unwrap_spec = [ObjSpace, int]
 
 def get_typeids_z(space):
     a = rgc.get_typeids_z()
     s = ''.join([a[i] for i in range(len(a))])
     return space.wrap(s)
-get_typeids_z.unwrap_spec = [ObjSpace]


More information about the Pypy-commit mailing list