Tim Peters added the comment:
I'm closing this. While it makes a big difference for a cwr coded in Python,
it turn out to be minor in C. The extra complications (more state to remember
and update across next() invocations) isn't worth the minor speedup in C.
--
resolution: -
Changes by Antoine Pitrou pit...@free.fr:
--
nosy: +serhiy.storchaka
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17930
___
___
Python-bugs-list
Raymond Hettinger added the comment:
Thanks Tim :-)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17930
___
___
Python-bugs-list mailing list
Changes by Terry J. Reedy tjre...@udel.edu:
--
nosy: +terry.reedy
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17930
___
___
Python-bugs-list
Tim Peters added the comment:
There's another savings to be had when an index becomes the maximum: in that
case, all the indices to its right are already at the maximum, so no need to
overwrite them. This isn't as big a savings as skipping the search, but still
buys about 10% more in the
New submission from Tim Peters:
Each time thru, CWR searches for the rightmost position not containing the
maximum index. But this is wholly determined by what happened the last time
thru - search isn't really needed. Here's Python code:
def cwr2(iterable, r):
pool = tuple(iterable)
Tim Peters added the comment:
Oops! Last part should read
since the indices vector is non-decreasing, if indices[j] was n-2 then
indices[j-1] is also at most n-2
That is, the instances of r-2 in the original should have been n-2.
--
___
Python