Author: Lukas Diekmann <[email protected]>
Branch: list-strategies
Changeset: r47523:de091db59f18
Date: 2011-08-02 14:03 +0200
http://bitbucket.org/pypy/pypy/changeset/de091db59f18/

Log:    added fastpath for mul with zero

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
@@ -406,10 +406,15 @@
         w_list.append(w_item)
 
     def mul(self, w_list, times):
-        l = self._getitems_range(w_list, False)
-        l *= times
-        strategy = self.space.fromcache(IntegerListStrategy)
-        storage = strategy.cast_to_void_star(l)
+        #XXX is this faster?
+        if times == 0:
+            strategy = self.space.fromcache(EmptyListStrategy)
+            storage = strategy.emptylist
+        else:
+            l = self._getitems_range(w_list, False)
+            l *= times
+            strategy = self.space.fromcache(IntegerListStrategy)
+            storage = strategy.cast_to_void_star(l)
         w_newlist = W_ListObject.from_storage_and_strategy(self.space, 
storage, strategy)
         return w_newlist
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to