[pypy-svn] r68820 - in pypy/branch/shrink-multidict/pypy: interpreter module/operator module/sys objspace objspace/std

cfbolz at codespeak.net cfbolz at codespeak.net
Wed Oct 28 15:26:32 CET 2009


Author: cfbolz
Date: Wed Oct 28 15:26:31 2009
New Revision: 68820

Modified:
   pypy/branch/shrink-multidict/pypy/interpreter/baseobjspace.py
   pypy/branch/shrink-multidict/pypy/interpreter/main.py
   pypy/branch/shrink-multidict/pypy/interpreter/mixedmodule.py
   pypy/branch/shrink-multidict/pypy/interpreter/pyopcode.py
   pypy/branch/shrink-multidict/pypy/module/operator/__init__.py
   pypy/branch/shrink-multidict/pypy/module/sys/__init__.py
   pypy/branch/shrink-multidict/pypy/objspace/descroperation.py
   pypy/branch/shrink-multidict/pypy/objspace/std/callmethod.py
   pypy/branch/shrink-multidict/pypy/objspace/std/inlinedict.py
   pypy/branch/shrink-multidict/pypy/objspace/std/objspace.py
   pypy/branch/shrink-multidict/pypy/objspace/std/proxyobject.py
   pypy/branch/shrink-multidict/pypy/objspace/std/typeobject.py
   pypy/branch/shrink-multidict/pypy/objspace/std/typetype.py
   pypy/branch/shrink-multidict/pypy/objspace/taint.py
Log:
make getdictvalue take an unwrapped string and kill getdictvalue_w


Modified: pypy/branch/shrink-multidict/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/branch/shrink-multidict/pypy/interpreter/baseobjspace.py	Wed Oct 28 15:26:31 2009
@@ -25,20 +25,14 @@
     def getdict(self):
         return None
 
-    def getdictvalue_w(self, space, attr):
+    def getdictvalue(self, space, attr):
         w_dict = self.getdict()
         if w_dict is not None:
             return space.finditem_str(w_dict, attr)
         return None
 
-    def getdictvalue(self, space, w_attr):
-        w_dict = self.getdict()
-        if w_dict is not None:
-            return space.finditem(w_dict, w_attr)
-        return None
-
     def getdictvalue_attr_is_in_class(self, space, attr):
-        return self.getdictvalue_w(space, attr)
+        return self.getdictvalue(space, attr)
 
     def setdictvalue(self, space, w_attr, w_value, shadows_type=True):
         w_dict = self.getdict()
@@ -285,7 +279,7 @@
                 self.timer.stop("startup " + modname)
 
     def finish(self):
-        w_exitfunc = self.sys.getdictvalue_w(self, 'exitfunc')
+        w_exitfunc = self.sys.getdictvalue(self, 'exitfunc')
         if w_exitfunc is not None:
             self.call_function(w_exitfunc)
         from pypy.interpreter.module import Module
@@ -778,7 +772,7 @@
         w_type = self.type(w_obj)
         w_mro = self.getattr(w_type, self.wrap("__mro__"))
         for w_supertype in self.unpackiterable(w_mro):
-            w_value = w_supertype.getdictvalue_w(self, name)
+            w_value = w_supertype.getdictvalue(self, name)
             if w_value is not None:
                 return w_value
         return None

Modified: pypy/branch/shrink-multidict/pypy/interpreter/main.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/interpreter/main.py	(original)
+++ pypy/branch/shrink-multidict/pypy/interpreter/main.py	Wed Oct 28 15:26:31 2009
@@ -149,11 +149,11 @@
                           w_traceback)
 
             # call sys.excepthook if present
-            w_hook = space.sys.getdictvalue_w(space, 'excepthook')
+            w_hook = space.sys.getdictvalue(space, 'excepthook')
             if w_hook is not None:
                 # hack: skip it if it wasn't modified by the user,
                 #       to do instead the faster verbose/nonverbose thing below
-                w_original = space.sys.getdictvalue_w(space, '__excepthook__')
+                w_original = space.sys.getdictvalue(space, '__excepthook__')
                 if w_original is None or not space.is_w(w_hook, w_original):
                     space.call_function(w_hook, w_type, w_value, w_traceback)
                     return False   # done

Modified: pypy/branch/shrink-multidict/pypy/interpreter/mixedmodule.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/interpreter/mixedmodule.py	(original)
+++ pypy/branch/shrink-multidict/pypy/interpreter/mixedmodule.py	Wed Oct 28 15:26:31 2009
@@ -32,7 +32,7 @@
 
     def get(self, name):
         space = self.space
-        w_value = self.getdictvalue_w(space, name) 
+        w_value = self.getdictvalue(space, name) 
         if w_value is None: 
             raise OperationError(space.w_AttributeError, space.wrap(name))
         return w_value 
@@ -41,18 +41,12 @@
         w_builtin = self.get(name) 
         return self.space.call_function(w_builtin, *args_w)
 
-    def getdictvalue_w(self, space, name):
+    def getdictvalue(self, space, name):
         w_value = space.finditem_str(self.w_dict, name)
         if self.lazy and w_value is None:
             return self._load_lazily(space, name)
         return w_value
 
-    def getdictvalue(self, space, w_name):
-        w_value = space.finditem(self.w_dict, w_name)
-        if self.lazy and w_value is None:
-            return self._load_lazily(space, space.str_w(w_name))
-        return w_value
-
     def _load_lazily(self, space, name):
         w_name = space.new_interned_str(name)
         try: 

Modified: pypy/branch/shrink-multidict/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/interpreter/pyopcode.py	(original)
+++ pypy/branch/shrink-multidict/pypy/interpreter/pyopcode.py	Wed Oct 28 15:26:31 2009
@@ -673,25 +673,24 @@
                 return
         f.LOAD_GLOBAL(nameindex)    # fall-back
 
-    def _load_global(f, w_varname):
-        w_value = f.space.finditem(f.w_globals, w_varname)
+    def _load_global(f, varname):
+        w_value = f.space.finditem_str(f.w_globals, varname)
         if w_value is None:
             # not in the globals, now look in the built-ins
-            w_value = f.get_builtin().getdictvalue(f.space, w_varname)
+            w_value = f.get_builtin().getdictvalue(f.space, varname)
             if w_value is None:
-                f._load_global_failed(w_varname)
+                f._load_global_failed(varname)
         return w_value
     _load_global._always_inline_ = True
 
-    def _load_global_failed(f, w_varname):
-        varname = f.space.str_w(w_varname)
+    def _load_global_failed(f, varname):
         message = "global name '%s' is not defined" % varname
         raise OperationError(f.space.w_NameError,
                              f.space.wrap(message))
     _load_global_failed._dont_inline_ = True
 
     def LOAD_GLOBAL(f, nameindex, *ignored):
-        f.pushvalue(f._load_global(f.getname_w(nameindex)))
+        f.pushvalue(f._load_global(f.getname_u(nameindex)))
     LOAD_GLOBAL._always_inline_ = True
 
     def DELETE_FAST(f, varindex, *ignored):
@@ -782,7 +781,7 @@
         else:
             w_flag = None
 
-        w_import = f.get_builtin().getdictvalue_w(f.space, '__import__')
+        w_import = f.get_builtin().getdictvalue(f.space, '__import__')
         if w_import is None:
             raise OperationError(space.w_ImportError,
                                  space.wrap("__import__ not found"))
@@ -989,8 +988,8 @@
     def CALL_LIKELY_BUILTIN(f, oparg, *ignored):
         # overridden by faster version in the standard object space.
         from pypy.module.__builtin__ import OPTIMIZED_BUILTINS
-        w_varname = f.space.wrap(OPTIMIZED_BUILTINS[oparg >> 8])
-        w_function = f._load_global(w_varname)
+        varname = OPTIMIZED_BUILTINS[oparg >> 8]
+        w_function = f._load_global(varname)
         nargs = oparg&0xFF
         try:
             w_result = f.space.call_valuestack(w_function, nargs, f)

Modified: pypy/branch/shrink-multidict/pypy/module/operator/__init__.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/module/operator/__init__.py	(original)
+++ pypy/branch/shrink-multidict/pypy/module/operator/__init__.py	Wed Oct 28 15:26:31 2009
@@ -9,7 +9,7 @@
 
     def __init__(self, space, w_name):
         def create_lambda(name, alsoname):
-            return lambda space : self.getdictvalue(space, space.wrap(alsoname))
+            return lambda space : self.getdictvalue(space, alsoname)
         
         MixedModule.__init__(self, space, w_name)
         for name, alsoname in self.mapping.iteritems():

Modified: pypy/branch/shrink-multidict/pypy/module/sys/__init__.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/module/sys/__init__.py	(original)
+++ pypy/branch/shrink-multidict/pypy/module/sys/__init__.py	Wed Oct 28 15:26:31 2009
@@ -100,9 +100,9 @@
         w_modules = self.get('modules')
         self.space.setitem(w_modules, w_name, w_module)
 
-    def getdictvalue_w(self, space, attr):
+    def getdictvalue(self, space, attr):
         """ specialize access to dynamic exc_* attributes. """ 
-        value = MixedModule.getdictvalue_w(self, space, attr) 
+        value = MixedModule.getdictvalue(self, space, attr) 
         if value is not None: 
             return value
         if attr == 'exc_type':
@@ -125,9 +125,6 @@
                 return space.wrap(operror.application_traceback)
         return None 
 
-    def getdictvalue(self, space, w_attr): 
-        return self.getdictvalue_w(space, space.str_w(w_attr))
-
     def get_w_default_encoder(self):
         if self.w_default_encoder is not None:
             # XXX is this level of caching ok?  CPython has some shortcuts

Modified: pypy/branch/shrink-multidict/pypy/objspace/descroperation.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/objspace/descroperation.py	(original)
+++ pypy/branch/shrink-multidict/pypy/objspace/descroperation.py	Wed Oct 28 15:26:31 2009
@@ -38,7 +38,7 @@
                 return space.get(w_descr, w_obj)
             w_value = w_obj.getdictvalue_attr_is_in_class(space, name)
         else:
-            w_value = w_obj.getdictvalue_w(space, name)
+            w_value = w_obj.getdictvalue(space, name)
         if w_value is not None:
             return w_value
         if w_descr is not None:

Modified: pypy/branch/shrink-multidict/pypy/objspace/std/callmethod.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/objspace/std/callmethod.py	(original)
+++ pypy/branch/shrink-multidict/pypy/objspace/std/callmethod.py	Wed Oct 28 15:26:31 2009
@@ -54,7 +54,7 @@
         if w_descr is None:
             # this handles directly the common case
             #   module.function(args..)
-            w_value = w_obj.getdictvalue_w(space, name)
+            w_value = w_obj.getdictvalue(space, name)
         elif type(w_descr) is function.Function:
             w_value = w_obj.getdictvalue_attr_is_in_class(space, name)
             if w_value is None:

Modified: pypy/branch/shrink-multidict/pypy/objspace/std/inlinedict.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/objspace/std/inlinedict.py	(original)
+++ pypy/branch/shrink-multidict/pypy/objspace/std/inlinedict.py	Wed Oct 28 15:26:31 2009
@@ -83,20 +83,14 @@
         def _inlined_dict_valid(self):
             return getattr(self, attrname) is not None
 
-        def getdictvalue_w(self, space, attr):
+        def getdictvalue(self, space, attr):
             if self._inlined_dict_valid():
                 return self.impl_getitem_str(attr)
             w_dict = self.getdict()
             return w_dict.getitem_str(attr)
 
-        def getdictvalue(self, space, w_attr):
-            if self._inlined_dict_valid():
-                return self.impl_getitem(w_attr)
-            w_dict = self.getdict()
-            return w_dict.getitem(w_attr)
-
         def getdictvalue_attr_is_in_class(self, space, attr):
-            return self.getdictvalue_w(space, attr)
+            return self.getdictvalue(space, attr)
 
         def setdictvalue(self, space, w_attr, w_value, shadows_type=True):
             if self._inlined_dict_valid():

Modified: pypy/branch/shrink-multidict/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/objspace/std/objspace.py	(original)
+++ pypy/branch/shrink-multidict/pypy/objspace/std/objspace.py	Wed Oct 28 15:26:31 2009
@@ -717,7 +717,7 @@
                 if not e.match(self, self.w_AttributeError):
                     raise
         else:
-            w_value = w_obj.getdictvalue_w(self, name)
+            w_value = w_obj.getdictvalue(self, name)
             if w_value is not None:
                 return w_value
 

Modified: pypy/branch/shrink-multidict/pypy/objspace/std/proxyobject.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/objspace/std/proxyobject.py	(original)
+++ pypy/branch/shrink-multidict/pypy/objspace/std/proxyobject.py	Wed Oct 28 15:26:31 2009
@@ -34,13 +34,10 @@
             raise OperationError(space.w_TypeError,
                                  space.wrap("You cannot override __class__ for transparent proxies"))
         
-        def getdictvalue_w(self, space, attr):
-            return self.getdictvalue(space, space.wrap(attr))
-
-        def getdictvalue(self, space, w_attr):
+        def getdictvalue(self, space, attr):
             try:
                 return space.call_function(self.w_controller, space.wrap('__getattribute__'),
-                   w_attr)
+                   space.wrap(attr))
             except OperationError, e:
                 if not e.match(space, space.w_AttributeError):
                     raise
@@ -67,19 +64,12 @@
                 return False
         
         def getdict(self):
-            return self.getdictvalue(self.space, self.space.wrap('__dict__'))
+            return self.getdictvalue(self.space, '__dict__')
         
         def setdict(self, space, w_dict):
             if not self.setdictvalue(space, space.wrap('__dict__'), w_dict):
                 baseobjspace.W_Root.setdict(self, space, w_dict)
         
-##        def __getattr__(self, attr):
-##            # NOT_RPYTHON
-##            try:
-##                return self.getdictvalue(self.space, self.space.wrap(attr))
-##            except OperationError, e:
-##                raise AttributeError(attr)
-        
     W_Transparent.__name__ = name
     return W_Transparent
 

Modified: pypy/branch/shrink-multidict/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/objspace/std/typeobject.py	(original)
+++ pypy/branch/shrink-multidict/pypy/objspace/std/typeobject.py	Wed Oct 28 15:26:31 2009
@@ -131,10 +131,7 @@
     def compute_default_mro(w_self):
         return compute_C3_mro(w_self.space, w_self)
 
-    def getdictvalue(w_self, space, w_attr):
-        return w_self.getdictvalue_w(space, space.str_w(w_attr))
-    
-    def getdictvalue_w(w_self, space, attr):
+    def getdictvalue(w_self, space, attr):
         w_value = w_self.dict_w.get(attr, None)
         if w_self.lazyloaders and w_value is None:
             if attr in w_self.lazyloaders:
@@ -172,7 +169,7 @@
             if w_class is w_starttype:
                 look = True
             elif look:
-                w_value = w_class.getdictvalue_w(space, name)
+                w_value = w_class.getdictvalue(space, name)
                 if w_value is not None:
                     return w_value
         return None
@@ -182,7 +179,7 @@
     def _lookup(w_self, key):
         space = w_self.space
         for w_class in w_self.mro_w:
-            w_value = w_class.getdictvalue_w(space, key)
+            w_value = w_class.getdictvalue(space, key)
             if w_value is not None:
                 return w_value
         return None
@@ -193,7 +190,7 @@
         # attribute was found
         space = w_self.space
         for w_class in w_self.mro_w:
-            w_value = w_class.getdictvalue_w(space, key)
+            w_value = w_class.getdictvalue(space, key)
             if w_value is not None:
                 return w_class, w_value
         return None, None
@@ -273,7 +270,7 @@
         "NOT_RPYTHON.  Forces the lazy attributes to be computed."
         if 'lazyloaders' in w_self.__dict__:
             for attr in w_self.lazyloaders.keys():
-                w_self.getdictvalue_w(w_self.space, attr)
+                w_self.getdictvalue(w_self.space, attr)
             del w_self.lazyloaders
         return False
 

Modified: pypy/branch/shrink-multidict/pypy/objspace/std/typetype.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/objspace/std/typetype.py	(original)
+++ pypy/branch/shrink-multidict/pypy/objspace/std/typetype.py	Wed Oct 28 15:26:31 2009
@@ -174,7 +174,7 @@
         return space.wrap("""type(object) -> the object's type
 type(name, bases, dict) -> a new type""")
     w_type = _check(space, w_type)
-    w_result = w_type.getdictvalue_w(space, '__doc__')
+    w_result = w_type.getdictvalue(space, '__doc__')
     if w_result is None:
         return space.w_None
     else:

Modified: pypy/branch/shrink-multidict/pypy/objspace/taint.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/objspace/taint.py	(original)
+++ pypy/branch/shrink-multidict/pypy/objspace/taint.py	Wed Oct 28 15:26:31 2009
@@ -20,11 +20,8 @@
 ##    def getdict(self):
 ##        return taint(self.w_obj.getdict())
 
-##    def getdictvalue_w(self, space, attr):
-##        return taint(self.w_obj.getdictvalue_w(space, attr))
-
-##    def getdictvalue(self, space, w_attr):
-##        return taint(self.w_obj.getdictvalue(space, w_attr))
+##    def getdictvalue(self, space, attr):
+##        return taint(self.w_obj.getdictvalue(space, attr))
 
 ##    def setdictvalue(self, space, w_attr, w_value):
 ##        return self.w_obj.setdictvalue(space, w_attr, w_value)



More information about the Pypy-commit mailing list