[pypy-commit] pypy list-strategies: extend any list with emptylist
l.diekmann
noreply at buildbot.pypy.org
Fri Sep 23 13:12:54 CEST 2011
Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: list-strategies
Changeset: r47487:d6d8f46ff357
Date: 2011-03-23 14:01 +0100
http://bitbucket.org/pypy/pypy/changeset/d6d8f46ff357/
Log: extend any list with emptylist
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
@@ -476,6 +476,8 @@
if self.list_is_correct_type(w_other):
l += self.cast_from_void_star(w_other.lstorage)
return
+ elif w_other.strategy is self.space.fromcache(EmptyListStrategy):
+ return
#XXX unnecessary copy if w_other is ObjectList
list_w = w_other.getitems()
diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py
--- a/pypy/objspace/std/test/test_liststrategies.py
+++ b/pypy/objspace/std/test/test_liststrategies.py
@@ -174,6 +174,12 @@
empty.extend(W_ListObject(self.space, []))
assert isinstance(empty.strategy, EmptyListStrategy)
+ def test_extend_other_with_empty(self):
+ l = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
+ assert isinstance(l.strategy, IntegerListStrategy)
+ l.extend(W_ListObject(self.space, []))
+ assert isinstance(l.strategy, IntegerListStrategy)
+
def test_rangelist(self):
l = make_range_list(self.space, 1,3,7)
assert isinstance(l.strategy, RangeListStrategy)
More information about the pypy-commit
mailing list