Re: Optimizing multiple dispatch
From: Jeff Epler (jepler_at_unpythonic.net)
Date: 06/03/04
- Next message: Paul Rubin: "Re: C compiler written in Python"
- Previous message: Heiko Wundram: "Re: Optimizing multiple dispatch"
- In reply to: Jacek Generowicz: "Re: Optimizing multiple dispatch"
- Next in thread: Jacek Generowicz: "Re: Optimizing multiple dispatch"
- Reply: Jacek Generowicz: "Re: Optimizing multiple dispatch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 3 Jun 2004 10:30:40 -0500 To: Jacek Generowicz <jacek.generowicz@cern.ch>
Pyrex is just a translator, there's no dependency on a Pyrex library or
include file when you actually want to compile the generated .c
On Thu, Jun 03, 2004 at 04:55:19PM +0200, Jacek Generowicz wrote:
> Jeff Epler <jepler@unpythonic.net> writes:
>
> > Avoding map() may help:
> > tuple([type(a) for a in args])
>
> Nonononononooooo! :-)
[...]
> > ... hmm, map is faster than listcomp. my mistake!
>
> :-)
>
> I've asked for optimization advice a few times here, and usually the
> responses include "replace map with a list comprehension" ... and yet
> the map is always faster. I wonder where people get this idea that map
> is slow ... until this started happening I had always assumed that
> "everyone" knows that the map/reduce/filter family are the fastest
> Python looping constructs.
No message about optimization should be without one downright wrong
suggestion.
The common wisdom about listcomp speed may apply when the body doesn't
include a function call, but the map version would include a lambda:
$ timeit 'map(lambda x:x+1, range(100))'
1000 loops, best of 3: 230 usec per loop
$ timeit '[x+1 for x in range(100)]'
10000 loops, best of 3: 156 usec per loop
Jeff
- application/pgp-signature attachment: stored
- Next message: Paul Rubin: "Re: C compiler written in Python"
- Previous message: Heiko Wundram: "Re: Optimizing multiple dispatch"
- In reply to: Jacek Generowicz: "Re: Optimizing multiple dispatch"
- Next in thread: Jacek Generowicz: "Re: Optimizing multiple dispatch"
- Reply: Jacek Generowicz: "Re: Optimizing multiple dispatch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|