[pypy-commit] pypy dynamic-specialized-tuple: (alex, fijal): progress
alex_gaynor
noreply at buildbot.pypy.org
Tue Mar 13 09:07:30 CET 2012
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: dynamic-specialized-tuple
Changeset: r53429:2b2568452f27
Date: 2012-03-13 00:00 -0700
http://bitbucket.org/pypy/pypy/changeset/2b2568452f27/
Log: (alex, fijal): 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
@@ -38,10 +38,12 @@
return self.tolist(space)
def length(self):
- return self.storage.length()
+ return self.storage.getlength()
def getitem(self, space, i):
- return self.shape.getitem(space, self.items, i)
+ from pypy.objspace.std.tupletype import read_obj
+
+ return read_obj(space, self.storage, i)
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
@@ -1,8 +1,10 @@
import sys
-from pypy.rlib.rerased_raw import UntypedStorage, INT, INSTANCE
+
from pypy.interpreter import gateway
+from pypy.interpreter.baseobjspace import W_Root
from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
+from pypy.rlib.rerased_raw import UntypedStorage, INT, INSTANCE
MAXIMUM_SPECIALIZED_SIZE = 8
@@ -26,6 +28,13 @@
else:
storage.setinstance(idx, w_obj)
+def read_obj(space, storage, idx):
+ char = storage.getshape()[idx]
+ if char == INT:
+ return space.wrap(storage.getint(idx))
+ else:
+ return storage.getinstance(idx, W_Root)
+
def make_tuple(space, w_tuple, list_w):
from pypy.objspace.std.tupleobject import W_TupleObject
More information about the pypy-commit
mailing list