Re: [Python-Dev] benchmarks: Force map to a list to guarantee the calculations are performed under

2012年9月30日 16:20:40 -0700

On Sun, Sep 30, 2012 at 7:11 PM, Antoine Pitrou <[email protected]> wrote:
> On Mon, 1 Oct 2012 01:00:42 +0200 (CEST)
> brett.cannon <[email protected]> wrote:
> > http://hg.python.org/benchmarks/rev/e9f911fd9bd3
> > changeset: 184:e9f911fd9bd3
> > user: Brett Cannon <[email protected]>
> > date: Sun Sep 30 19:00:32 2012 -0400
> > summary:
> > Force map to a list to guarantee the calculations are performed under
> > Python 3.
> [...]
> > def eval_times_u(func, u):
> > - return map(func, ((i,u) for i in xrange(len(list(u)))))
> > + return list(imap(func, ((i,u) for i in xrange(len(list(u))))))
>
> Ugh, can't you use a list comprehension instead? The code would be much
> more idiomatic.
>
Done. Just went with the fastest fix without thinking.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to