[pypy-commit] pypy list-strategies: added fastpath for mul with zero
l.diekmann
noreply at buildbot.pypy.org
Fri Sep 23 13:14:52 CEST 2011
Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
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
More information about the pypy-commit
mailing list