Author: Mark Pearse <[email protected]>
Branch: SpecialisedTuples
Changeset: r49105:538c174c8197
Date: 2011-11-07 13:05 +0100
http://bitbucket.org/pypy/pypy/changeset/538c174c8197/
Log: (mwp) use a tuple of types as parameter to make_specialised_class
diff --git a/pypy/objspace/std/specialisedtupleobject.py
b/pypy/objspace/std/specialisedtupleobject.py
--- a/pypy/objspace/std/specialisedtupleobject.py
+++ b/pypy/objspace/std/specialisedtupleobject.py
@@ -64,11 +64,13 @@
def unwrap(w_tuple, space):
return tuple(self.tolist)
-def make_specialised_class(class_name, type0, type1):
+
+def make_specialised_class(class_name, typelist):
class cls(W_SpecialisedTupleObject):
def __init__(self, space, val0, val1):
- assert isinstance(val0, type0)
- assert isinstance(val1, type1)
+ assert len(typelist) == 2
+ assert isinstance(val0, typelist[0])
+ assert isinstance(val1, typelist[1])
self.space = space
self.val0 = val0
self.val1 = val1
@@ -160,13 +162,13 @@
return self.space.wrap(self.val1)
raise IndexError
cls.__name__ = class_name
- _specialisations.append((cls,(type0,type1)))
+ _specialisations.append((cls,typelist))
return cls
-W_SpecialisedTupleObjectIntInt =
make_specialised_class('W_SpecialisedTupleObjectIntInt', int,int)
-W_SpecialisedTupleObjectFloatFloat =
make_specialised_class('W_SpecialisedTupleObjectFloatFloat', float,float)
-W_SpecialisedTupleObjectStrStr =
make_specialised_class('W_SpecialisedTupleObjectStrStr', str, str)
+W_SpecialisedTupleObjectIntInt =
make_specialised_class('W_SpecialisedTupleObjectIntInt', (int,int))
+W_SpecialisedTupleObjectFloatFloat =
make_specialised_class('W_SpecialisedTupleObjectFloatFloat', (float,float))
+W_SpecialisedTupleObjectStrStr =
make_specialised_class('W_SpecialisedTupleObjectStrStr', (str, str))
registerimplementation(W_SpecialisedTupleObject)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit