This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients Thorney, rhettinger, westurner
Date 2013-07-20.09:11:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1374311490.88.0.997383574463.issue18511@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2013-07-20 09:11:30rhettingersetrecipients: + rhettinger, Thorney, westurner
2013-07-20 09:11:30rhettingersetmessageid: <1374311490.88.0.997383574463.issue18511@psf.upfronthosting.co.za>
2013-07-20 09:11:30rhettingerlinkissue18511 messages
2013-07-20 09:11:30rhettingercreate