[issue17930] Search not needed in combinations_with_replacement

2013-09-02 Thread Tim Peters
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: -

[issue17930] Search not needed in combinations_with_replacement

2013-08-15 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17930 ___ ___ Python-bugs-list

[issue17930] Search not needed in combinations_with_replacement

2013-05-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks Tim :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17930 ___ ___ Python-bugs-list mailing list

[issue17930] Search not needed in combinations_with_replacement

2013-05-10 Thread Terry J. Reedy
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

[issue17930] Search not needed in combinations_with_replacement

2013-05-08 Thread Tim Peters
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

[issue17930] Search not needed in combinations_with_replacement

2013-05-07 Thread Tim Peters
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)

[issue17930] Search not needed in combinations_with_replacement

2013-05-07 Thread Tim Peters
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