[pypy-svn] r7420 - in pypy/trunk/src/pypy: annotation objspace/std tool

mwh at codespeak.net mwh at codespeak.net
Fri Nov 19 11:56:42 CET 2004


Author: mwh
Date: Fri Nov 19 11:56:42 2004
New Revision: 7420

Modified:
   pypy/trunk/src/pypy/annotation/factory.py
   pypy/trunk/src/pypy/objspace/std/objspace.py
   pypy/trunk/src/pypy/tool/cache.py
Log:
Tweaks to specialization: if present, the attribute must be one of a 
known set of strings, currently "location" or "argtypes".

Also, the attribute is renamed to "_specialize_" -- a more special
name is indicated because we're about to make it mean something on
classes...


Modified: pypy/trunk/src/pypy/annotation/factory.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/factory.py	(original)
+++ pypy/trunk/src/pypy/annotation/factory.py	Fri Nov 19 11:56:42 2004
@@ -163,15 +163,17 @@
             func = func.im_func
         assert isinstance(func, FunctionType), "expected function, got %r"%func
         # do we need to specialize this function in several versions?
-        x = getattr(func, 'specialize', False)
-        if x: 
+        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:
+            elif x == "location":
                 # fully specialize: create one version per call position
                 func = self.specialize_by_key(func, self.position_key)
+            else:
+                raise Exception, "unsupported specialization type '%s'"%(x,)
             
         elif func.func_code.co_flags & CO_VARARGS:
             # calls to *arg functions: create one version per number of 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	Fri Nov 19 11:56:42 2004
@@ -262,7 +262,7 @@
             return self.gettypeobject(ft.typedef)
         ft = self.loadfromcache(type(x), fake_type, self._faketypecache)
         return ft(self, x)
-    wrap.specialize = "argtypes"
+    wrap._specialize_ = "argtypes"
 
     def newint(self, intval):
         return W_IntObject(self, intval)

Modified: pypy/trunk/src/pypy/tool/cache.py
==============================================================================
--- pypy/trunk/src/pypy/tool/cache.py	(original)
+++ pypy/trunk/src/pypy/tool/cache.py	Fri Nov 19 11:56:42 2004
@@ -30,7 +30,7 @@
             return self.setdefault(key, builder(key, space))
     # note to annotator: we want loadfromcache() to be 
     # specialized for the different cache types 
-    getorbuild.specialize = True 
+    getorbuild._specialize_ = "location"
 
     def freeze(self):
         del self.frozen 



More information about the Pypy-commit mailing list