Author: Lukas Diekmann <lukas.diekm...@uni-duesseldorf.de> Branch: list-strategies Changeset: r47477:24c514951069 Date: 2011-03-16 15:26 +0100 http://bitbucket.org/pypy/pypy/changeset/24c514951069/
Log: Just create a copy from storage when extending an 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 @@ -233,9 +233,9 @@ self.append(w_list, w_item) def extend(self, w_list, w_other): - #XXX items are wrapped and unwrapped again - w_list.strategy = w_other.strategy - w_list.strategy.init_from_list_w(w_list, w_other.getitems()) + strategy = w_list.strategy = w_other.strategy + items = strategy.cast_from_void_star(w_other.storage)[:] # copy! + w_list.storage = strategy.cast_to_void_star(items) def reverse(self, w_list): pass diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py --- a/pypy/objspace/std/test/test_listobject.py +++ b/pypy/objspace/std/test/test_listobject.py @@ -378,6 +378,14 @@ l.extend([10]) assert l == range(11) + l = [] + m = [1,2,3] + l.extend(m) + m[0] = 5 + assert m == [5,2,3] + assert l == [1,2,3] + + def test_extend_tuple(self): l = l0 = [1] l.extend((2,)) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit