Random passwords generation (Python vs Perl) =)
Steven D'Aprano
steve at REMOVEME.cybersource.com.au
Mon Jan 29 20:59:39 EST 2007
More information about the Python-list mailing list
Mon Jan 29 20:59:39 EST 2007
- Previous message (by thread): Random passwords generation (Python vs Perl) =)
- Next message (by thread): Random passwords generation (Python vs Perl) =)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, 29 Jan 2007 08:38:13 -0800, Szabolcs Nagy wrote:
>>> why use xrange? range is faster and simpler for small ranges
That is not true.
>>> import timeit
>>> timeit.Timer("range(50)", "").repeat()
[2.8599629402160645, 2.8296849727630615, 2.8609859943389893]
>>> timeit.Timer("xrange(50)", "").repeat()
[1.1806831359863281, 1.3563210964202881, 1.1632850170135498]
>>> timeit.Timer("range(5)", "").repeat()
[1.7963159084320068, 1.5487189292907715, 1.5596699714660645]
>>> timeit.Timer("xrange(5)", "").repeat()
[1.158560037612915, 1.1807279586791992, 1.1769890785217285]
There is very little reason to use range() unless you actually need the
entire list in one go. In fact, in Python 3.0, the existing range() will
be removed and xrange() will be renamed range().
--
Steven D'Aprano
- Previous message (by thread): Random passwords generation (Python vs Perl) =)
- Next message (by thread): Random passwords generation (Python vs Perl) =)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list