[PATCH 00 of 24] PYTHONHASHSEED=random
Pierre-Yves David
pierre-yves.david at logilab.fr
Tue Dec 18 04:07:19 CST 2012
On Tue, Dec 18, 2012 at 03:34:37AM +0100, Mads Kiilerich wrote:
> Bryan O'Sullivan wrote, On 12/17/2012 10:06 PM:
> A general comment to .iteritems() or not:
>
> It is obvious to use .iteritems() in "for x in d.iteritems()" to
> yield the items lazily, but the advantage becomes less obvious when
> the a sorter() is added. Then we could just as well focus in
> readability and making the code short.
>
> Some timeit benchmarking showed that:
>
> sorted(d.items()) is faster for few items (because it avoids the
> overhead of generating an iterator?).
>
> sorted(d.iteritems()) is faster for something like more than 1000
> items (because it avoids creating an extra list and adjusting
> reference counts several times)?.
>
> (and similarly, sorted(d.keys()) is often faster than sorted(d).)
you should try in place sorting
items = d.items()
items.sort()
for x in items:
pass
--
Pierre-Yves David
http://www.logilab.fr/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121218/c3d8830f/attachment.pgp>
More information about the Mercurial-devel
mailing list