[pypy-commit] pypy release-2.6.x: Move the slow-path loop out of this RPython function

arigo noreply at buildbot.pypy.org
Tue Sep 29 09:07:19 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: release-2.6.x
Changeset: r79886:a85f01242676
Date: 2015-09-29 09:07 +0200
http://bitbucket.org/pypy/pypy/changeset/a85f01242676/

Log:	Move the slow-path loop out of this RPython function

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
@@ -1396,16 +1396,19 @@
         else:
             subitems_w = [self._none_value] * length
             l = self.unerase(w_list.lstorage)
-            for i in range(length):
-                try:
-                    subitems_w[i] = l[start]
-                    start += step
-                except IndexError:
-                    raise
+            self._fill_in_with_sliced_items(subitems_w, l, start, step, length)
             storage = self.erase(subitems_w)
             return W_ListObject.from_storage_and_strategy(
                     self.space, storage, self)
 
+    def _fill_in_with_sliced_items(self, subitems_w, l, start, step, length):
+        for i in range(length):
+            try:
+                subitems_w[i] = l[start]
+                start += step
+            except IndexError:
+                raise
+
     def switch_to_next_strategy(self, w_list, w_sample_item):
         w_list.switch_to_object_strategy()
 


More information about the pypy-commit mailing list