Author: Alex Gaynor <[email protected]>
Branch: dynamic-specialized-tuple
Changeset: r53427:a2e43acd1ad0
Date: 2012-03-12 23:51 -0700
http://bitbucket.org/pypy/pypy/changeset/a2e43acd1ad0/
Log: (fijal, alex): random progress
diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py
--- a/pypy/objspace/std/tupleobject.py
+++ b/pypy/objspace/std/tupleobject.py
@@ -25,9 +25,8 @@
class W_TupleObject(W_AbstractTupleObject):
from pypy.objspace.std.tupletype import tuple_typedef as typedef
- def __init__(self, shape, items):
- self.shape = shape
- self.items = items
+ def __init__(self, storage):
+ self.storage = storage
def tolist(self, space):
items_w = [None] * self.length()
@@ -39,53 +38,11 @@
return self.tolist(space)
def length(self):
- return self.shape.length(self.items)
+ return self.storage.length()
def getitem(self, space, i):
return self.shape.getitem(space, self.items, i)
-
-class BaseShapeType(object):
- def wrap(self, space, items, i):
- raise NotImplementedError
-
-class ObjectShapeType(BaseShapeType):
- def getitem(self, space, items, i):
- return items[i]
-
-class BaseShape(object):
- pass
-
-class Shape(BaseShape):
- def __init__(self, shapetypes):
- self.shapetypes = shapetypes
-
- def length(self, items):
- return len(self.shapetypes)
-
- def getitem(self, space, items, i):
- return self.shapetypes[i].getitem(space, items, i)
-
-class LargeShape(BaseShape):
- def length(self, items):
- return len(items)
-
- def getitem(self, space, items, i):
- return items[i]
-
-class ShapeCache(object):
- def __init__(self, space):
- self._shapes = {}
- self.large_shape = LargeShape()
- self.object_shapetype = ObjectShapeType()
-
- def find_shape(self, types):
- return self._shapes.setdefault(tuple(types), Shape(types))
-
-def get_shape_cache(space):
- return space.fromcache(ShapeCache)
-
-
registerimplementation(W_TupleObject)
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
@@ -22,12 +22,12 @@
def store_obj(space, storage, idx, w_obj):
if space.is_w(space.type(w_obj), space.w_int):
- w_tuple.storage.setint(idx, space.int_w(w_obj))
+ storage.setint(idx, space.int_w(w_obj))
else:
- w_tuple.storage.setinstance(idx, w_obj)
+ storage.setinstance(idx, w_obj)
def make_tuple(space, w_tuple, list_w):
- from pypy.objspace.std.tupleobject import W_TupleObject, get_shape_cache
+ from pypy.objspace.std.tupleobject import W_TupleObject
shape_chars = ["\x00"] * len(list_w)
for i, w_item in enumerate(list_w):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit