[pypy-commit] pypy list-strategies: Stop must not be negative (translation fix); Wrapping/Unwrapping not neccessary here
l.diekmann
noreply at buildbot.pypy.org
Fri Sep 23 13:12:25 CEST 2011
Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: list-strategies
Changeset: r47466:a88228a2c43d
Date: 2011-03-15 16:27 +0100
http://bitbucket.org/pypy/pypy/changeset/a88228a2c43d/
Log: Stop must not be negative (translation fix); Wrapping/Unwrapping not
neccessary here
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -78,8 +78,8 @@
def switch_to_object_strategy(self):
list_w = self.getitems()
- self.strategy = self.space.fromcache(ObjectListStrategy)
- self.strategy.init_from_list_w(self, list_w)
+ strategy = self.strategy = self.space.fromcache(ObjectListStrategy)
+ strategy.init_from_list_w(self, list_w)
def check_empty_strategy(self):
if self.length() == 0:
@@ -416,10 +416,11 @@
def getslice(self, w_list, start, stop, step, length):
if step == 1:
- # XXX ineffecient cause items are wrapped and unwrapped again
- # later: W_ListObject constructor for unwrapped items
- l = w_list.getitems()
- return W_ListObject(self.space, l[start:stop])
+ l = self.cast_from_void_star(w_list.storage)
+ assert stop >= 0
+ sublist = l[start:stop]
+ storage = self.cast_to_void_star(sublist)
+ return W_ListObject.from_storage_and_strategy(self.space, storage, self)
else:
subitems_w = [None] * length
for i in range(length):
@@ -598,6 +599,8 @@
def init_from_list_w(self, w_list, list_w):
w_list.storage = self.cast_to_void_star(list_w)
+ # XXX implement getitems without copying here
+
class IntegerListStrategy(AbstractUnwrappedStrategy, ListStrategy):
def wrap(self, intval):
More information about the pypy-commit
mailing list