[pypy-commit] pypy default: (l.diekmann, cfbolz): prepared supporting differently sized small tuples

l.diekmann noreply at buildbot.pypy.org
Wed May 25 16:47:24 CEST 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: 
Changeset: r44423:24de77c03098
Date: 2011-01-18 14:05 +0100
http://bitbucket.org/pypy/pypy/changeset/24de77c03098/

Log:	(l.diekmann, cfbolz): prepared supporting differently sized small
	tuples

diff --git a/pypy/objspace/std/smalltupleobject.py b/pypy/objspace/std/smalltupleobject.py
--- a/pypy/objspace/std/smalltupleobject.py
+++ b/pypy/objspace/std/smalltupleobject.py
@@ -13,10 +13,18 @@
 class W_SmallTupleObject(W_Object):
     from pypy.objspace.std.tupletype import tuple_typedef as typedef
 
+    def tolist(self):
+        raise NotImplementedError
+
+class W_SmallTupleObject2(W_SmallTupleObject):
+
     def __init__(self, w_value01, w_value02):
         self.w_value01 = w_value01
         self.w_value02 = w_value02
 
+    def tolist(self):
+        return [self.w_value01, self.w_value02]
+
 registerimplementation(W_SmallTupleObject)
 
 def delegate_SmallTuple2Tuple(space, w_small):
diff --git a/pypy/objspace/std/tupletype.py b/pypy/objspace/std/tupletype.py
--- a/pypy/objspace/std/tupletype.py
+++ b/pypy/objspace/std/tupletype.py
@@ -5,9 +5,9 @@
 
 def wraptuple(space, list_w):
     from pypy.objspace.std.tupleobject import W_TupleObject
-    from pypy.objspace.std.smalltupleobject import W_SmallTupleObject
+    from pypy.objspace.std.smalltupleobject import W_SmallTupleObject2
     if space.config.objspace.std.withsmalltuple and len(list_w) == 2:
-        return W_SmallTupleObject(list_w[0], list_w[1])
+        return W_SmallTupleObject2(list_w[0], list_w[1])
     else:
         return W_TupleObject(list_w)
 


More information about the pypy-commit mailing list