[issue18511] random.shuffle could be faster

2013-07-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: Both versions loop over the exact same iterator, so both loops run at the same speed once they are started up. Your timeit code isn't measuring shuffle(). Instead, it measures list() which knows how to extract a useful length hint from xrange() but not

[issue18511] random.shuffle could be faster

2013-07-19 Thread Brian Thorne
Brian Thorne added the comment: Just did some testing on 2.7 and 3.3 on Windows and Ubuntu, the speedup is just noticeable - but much less so as the list grows. -- nosy: +Thorney ___ Python tracker __

[issue18511] random.shuffle could be faster

2013-07-19 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- Removed message: http://bugs.python.org/msg193399 ___ Python tracker ___ ___ Python-bugs-list mailin

[issue18511] random.shuffle could be faster

2013-07-19 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- priority: normal -> low versions: -3rd party, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.5 ___ Python tracker ___ __

[issue18511] random.shuffle could be faster

2013-07-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: The reversed() call is only executed once and is not inside the loop body, so its runtime is irrelevant to most shuffles. Also, the reason that reversed() is used is that is adds clarity to the code. -- ___ Pyt

[issue18511] random.shuffle could be faster

2013-07-19 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue18511] random.shuffle could be faster

2013-07-19 Thread Wes Turner
Wes Turner added the comment: Added patch to random.shuffle for trunk -- Added file: http://bugs.python.org/file30985/random-shuffle_trunk.patch ___ Python tracker ___ __

[issue18511] random.shuffle could be faster

2013-07-19 Thread Wes Turner
Wes Turner added the comment: Added patch to random.shuffle for v2.7.5 -- keywords: +patch Added file: http://bugs.python.org/file30984/random-shuffle_v2.7.5.patch ___ Python tracker ___

[issue18511] random.shuffle could be faster

2013-07-19 Thread Wes Turner
New submission from Wes Turner: random.shuffle [1][2] could be faster. ``xrange(10,1,-1)`` is faster than ``reversed(xrange(1,10))``. [1] http://hg.python.org/cpython/file/v3.3.2/Lib/random.py#l254 [2] http://hg.python.org/cpython/file/v2.7.5/Lib/random.py#l276 -- components: Library