[pypy-commit] pypy list-strategies: Implemented reverse
l.diekmann
noreply at buildbot.pypy.org
Fri Sep 23 13:11:42 CEST 2011
Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: list-strategies
Changeset: r47439:82ea67038f92
Date: 2011-02-25 12:12 +0100
http://bitbucket.org/pypy/pypy/changeset/82ea67038f92/
Log: Implemented reverse
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
@@ -111,6 +111,9 @@
def extend(self, items_w):
self.strategy.extend(self, items_w)
+ def reverse(self):
+ self.strategy.reverse(self)
+
registerimplementation(W_ListObject)
@@ -157,6 +160,9 @@
def extend(self, w_list, items_w):
raise NotImplementedError
+ def reverse(self, w_list):
+ raise NotImplementedError
+
class EmptyListStrategy(ListStrategy):
def init_from_list_w(self, w_list, list_w):
assert len(list_w) == 0
@@ -214,6 +220,9 @@
w_list.strategy = w_other.strategy
w_list.strategy.init_from_list_w(w_list, w_other.getitems())
+ def reverse(self, w_list):
+ pass
+
class AbstractUnwrappedStrategy(ListStrategy):
def unwrap(self, w_obj):
# XXX override later
@@ -405,6 +414,9 @@
list_w = self.cast_from_void_star(w_list.storage)
list_w *= times
+ def reverse(self, w_list):
+ self.cast_from_void_star(w_list.storage).reverse()
+
class ObjectListStrategy(AbstractUnwrappedStrategy):
def cast_from_void_star(self, storage):
return cast_from_void_star(storage, "object")
@@ -741,7 +753,7 @@
return space.wrap(count)
def list_reverse__List(space, w_list):
- w_list.wrappeditems.reverse()
+ w_list.reverse()
return space.w_None
# ____________________________________________________________
More information about the pypy-commit
mailing list