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 from an xrange 
iterator.  The timing difference disappears if you add iter():

   current = '''list(reversed(xrange(1, n)))'''
   proposd = '''list(iter(xrange(n, 1, -1)))'''

If you were to time shuffle() directly, you would see almost no difference 
between the current version and the patched version (there is a small 
difference in startup time due to the lookup of the reversed() built-in, but 
that is it).

----------
resolution:  -> invalid
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18511>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to