[issue5986] Avoid reversed() in Random.shuffle()

2009-05-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, the inefficiency is only in the loop setup, the time to call reversed() and __reversed__(). The inner loop runs at the same speed because xrange provides a __reversed__ iterator. Please do not go through the standard library making these minor tweaks

[issue5986] Avoid reversed() in Random.shuffle()

2009-05-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: -1 on this patch. Reversed has a very low overhead. Readability if more important. The current code is self-evidently correct but the patched code is less obviously so. -- ___ Python tracker

[issue5986] Avoid reversed() in Random.shuffle()

2009-05-10 Thread Benjamin Peterson
Changes by Benjamin Peterson : -- assignee: -> rhettinger nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list U

[issue5986] Avoid reversed() in Random.shuffle()

2009-05-10 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- priority: -> normal stage: -> patch review type: -> performance versions: +Python 2.7, Python 3.1 ___ Python tracker ___

[issue5986] Avoid reversed() in Random.shuffle()

2009-05-10 Thread STINNER Victor
New submission from STINNER Victor : reversed(xrange(1, len(x))) is inefficient, xrange(len(x) - 1, 0, -1) gives exactly the same sequence but avoid reversed(). See attached patch. Don't expect amazing speedup. -- components: Library (Lib) files: shuffle.patch keywords: patch messages: