[pypy-commit] pypy speedup-list-comprehension: clean up changes
fijal
noreply at buildbot.pypy.org
Mon Mar 12 00:09:46 CET 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: speedup-list-comprehension
Changeset: r53306:d11c5cf98a00
Date: 2012-03-11 16:09 -0700
http://bitbucket.org/pypy/pypy/changeset/d11c5cf98a00/
Log: clean up changes
diff --git a/pypy/rpython/lltypesystem/rlist.py b/pypy/rpython/lltypesystem/rlist.py
--- a/pypy/rpython/lltypesystem/rlist.py
+++ b/pypy/rpython/lltypesystem/rlist.py
@@ -319,18 +319,15 @@
ll_assert(length >= 0, "negative fixed list length")
l = malloc(LIST, length)
return l
-ll_fixed_newlist = typeMethod(ll_fixed_newlist)
ll_fixed_newlist.oopspec = 'newlist(length)'
@typeMethod
def ll_fixed_newemptylist(LIST):
return ll_fixed_newlist(LIST, 0)
-ll_fixed_newemptylist = typeMethod(ll_fixed_newemptylist)
def ll_fixed_length(l):
return len(l)
ll_fixed_length.oopspec = 'list.len(l)'
-ll_fixed_length._always_inline_ = True
def ll_fixed_items(l):
return l
@@ -394,7 +391,11 @@
('list', r_list.lowleveltype),
('index', Signed)))
self.ll_listiter = ll_listiter
- self.ll_listnext = ll_listnext
+ if (isinstance(r_list, FixedSizeListRepr)
+ and not r_list.listitem.mutated):
+ self.ll_listnext = ll_listnext_foldable
+ else:
+ self.ll_listnext = ll_listnext
self.ll_getnextindex = ll_getnextindex
def ll_listiter(ITERPTR, lst):
@@ -411,5 +412,14 @@
iter.index = index + 1 # cannot overflow because index < l.length
return l.ll_getitem_fast(index)
+def ll_listnext_foldable(iter):
+ from pypy.rpython.rlist import ll_getitem_foldable_nonneg
+ l = iter.list
+ index = iter.index
+ if index >= l.ll_length():
+ raise StopIteration
+ iter.index = index + 1 # cannot overflow because index < l.length
+ return ll_getitem_foldable_nonneg(l, index)
+
def ll_getnextindex(iter):
return iter.index
diff --git a/pypy/rpython/rlist.py b/pypy/rpython/rlist.py
--- a/pypy/rpython/rlist.py
+++ b/pypy/rpython/rlist.py
@@ -559,7 +559,7 @@
def ll_len_foldable(l):
return l.ll_length()
-ll_len_foldable._always_inline_ = True
+ll_len_foldable.oopspec = 'list.len_foldable(l)'
def ll_list_is_true_foldable(l):
return bool(l) and ll_len_foldable(l) != 0
More information about the pypy-commit
mailing list