Dict comprehensions - improvement to docs?

Paul Rubin no.email at nospam.invalid
Mon Mar 16 04:38:13 EDT 2015


"Frank Millman" <frank at chagford.com> writes:
> dict((a, b) for a, b in zip(x, y))
> 100000 loops, best of 3: 16.1 usec per loop
> {a: b for a, b in zip(x, y)}"
> 100000 loops, best of 3: 6.38 usec per loop

Hmm, I bet the difference is from the (a,b) consing all those tuples.

Can you try just dict(zip(x,y))  ?



More information about the Python-list mailing list