[pypy-commit] pypy length-hint: restore the original list init special cases for now

pjenvey noreply at buildbot.pypy.org
Mon Nov 12 03:31:32 CET 2012


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: length-hint
Changeset: r58835:52b004b643b7
Date: 2012-11-11 17:00 -0800
http://bitbucket.org/pypy/pypy/changeset/52b004b643b7/

Log:	restore the original list init special cases for now

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
@@ -548,6 +548,29 @@
     def _extend_from_list(self, w_list, w_other):
         w_other.copy_into(w_list)
 
+    def _extend_from_iterable(self, w_list, w_iterable):
+        from pypy.objspace.std.tupleobject import W_AbstractTupleObject
+        space = self.space
+        if isinstance(w_iterable, W_AbstractTupleObject):
+            w_list.__init__(space, w_iterable.getitems_copy())
+            return
+
+        intlist = space.listview_int(w_iterable)
+        if intlist is not None:
+            w_list.strategy = strategy = space.fromcache(IntegerListStrategy)
+            # need to copy because intlist can share with w_iterable
+            w_list.lstorage = strategy.erase(intlist[:])
+            return
+
+        strlist = space.listview_str(w_iterable)
+        if strlist is not None:
+            w_list.strategy = strategy = space.fromcache(StringListStrategy)
+            # need to copy because intlist can share with w_iterable
+            w_list.lstorage = strategy.erase(strlist[:])
+            return
+
+        ListStrategy._extend_from_iterable(self, w_list, w_iterable)
+
     def reverse(self, w_list):
         pass
 


More information about the pypy-commit mailing list