[pypy-svn] r5273 - pypy/trunk/src/pypy/objspace/std

arigo at codespeak.net arigo at codespeak.net
Thu Jun 24 18:51:18 CEST 2004


Author: arigo
Date: Thu Jun 24 18:51:17 2004
New Revision: 5273

Modified:
   pypy/trunk/src/pypy/objspace/std/multimethod.py
Log:
* Removed a deprecated multimethod hack.
* Added BoundMultiMethod.__eq__() to ensure that
  space.xxx == space.xxx for each multimethod xxx.


Modified: pypy/trunk/src/pypy/objspace/std/multimethod.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/multimethod.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/multimethod.py	Thu Jun 24 18:51:17 2004
@@ -35,8 +35,6 @@
     """Abstract base class for MultiMethod and UnboundMultiMethod
     i.e. the classes that are not bound to a specific space instance."""
 
-    class BASE_TYPE_OBJECT: pass
-
     def __init__(self, operatorsymbol, arity):
         self.arity = arity
         self.operatorsymbol = operatorsymbol
@@ -277,11 +275,9 @@
         self.unbound_versions = {}
 
 
-    def __get__(self, space, cls=object): # cls is some W_xxxType
-        if issubclass(cls, self.BASE_TYPE_OBJECT):
-            return self.slice(cls).get(space)
-        elif space is None:
-            return self  # hack for "StdObjSpace.xyz" returning xyz
+    def __get__(self, space, cls=None):
+        if space is None:
+            return self
         else:
             return BoundMultiMethod(space, self)
 
@@ -401,6 +397,17 @@
         self.space = space
         self.multimethod = multimethod
 
+    def __eq__(self, other):
+        return (self.__class__ == other.__class__ and
+                self.space == other.space and
+                self.multimethod == other.multimethod)
+
+    def __ne__(self, other):
+        return self != other
+
+    def __hash__(self):
+        return hash((self.__class__, self.space, self.multimethod))
+
     def __call__(self, *args):
         if len(args) < self.multimethod.arity:
             raise TypeError, ("multimethod needs at least %d arguments" %



More information about the Pypy-commit mailing list