[pypy-svn] r7388 - in pypy/trunk/src/pypy: annotation objspace/std
hpk at codespeak.net
hpk at codespeak.net
Thu Nov 18 17:29:44 CET 2004
Author: hpk
Date: Thu Nov 18 17:29:44 2004
New Revision: 7388
Modified:
pypy/trunk/src/pypy/annotation/factory.py
pypy/trunk/src/pypy/objspace/std/objspace.py
Log:
specialize objspace.wrap by argument types
(gets rid of lots of SomeObjects())
IOW, you can use "function.specialize = 'argtypes'"
to cause the annotator to specialize for argument types
Modified: pypy/trunk/src/pypy/annotation/factory.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/factory.py (original)
+++ pypy/trunk/src/pypy/annotation/factory.py Thu Nov 18 17:29:44 2004
@@ -163,9 +163,16 @@
func = func.im_func
assert isinstance(func, FunctionType), "expected function, got %r"%func
# do we need to specialize this function in several versions?
- if getattr(func, 'specialize', False):
- # fully specialize: create one version per call position
- func = self.specialize_by_key(func, self.position_key)
+ x = getattr(func, 'specialize', False)
+ if x:
+ if x == 'argtypes':
+ key = "_".join([arg.__class__.__name__ for arg in args])
+ name = func.__name__+'_'+key
+ func = self.specialize_by_key(func, key, name)
+ else:
+ # fully specialize: create one version per call position
+ func = self.specialize_by_key(func, self.position_key)
+
elif func.func_code.co_flags & CO_VARARGS:
# calls to *arg functions: create one version per number of args
func = self.specialize_by_key(func, len(args),
Modified: pypy/trunk/src/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/objspace.py (original)
+++ pypy/trunk/src/pypy/objspace/std/objspace.py Thu Nov 18 17:29:44 2004
@@ -262,6 +262,7 @@
return self.gettypeobject(ft.typedef)
ft = self.loadfromcache(type(x), fake_type, self._faketypecache)
return ft(self, x)
+ wrap.specialize = "argtypes"
def newint(self, intval):
return W_IntObject(self, intval)
More information about the Pypy-commit
mailing list