Optimizing multiple dispatch
Carl Banks
imbosol at aerojockey.com
Thu Jun 3 18:42:52 EDT 2004
Jeff Epler <jepler at unpythonic.net> wrote in message news:<mailman.547.1086270969.6949.python-list at python.org>...
> Avoding map() may help:
> tuple([type(a) for a in args])
[snip]
>
> ... hmm, map is faster than listcomp. my mistake!
Rule of thumb: listcomp is only faster than map if it avoids an extra
function call. So, for example, "[ x+1 for x in xs ]" is probably
faster than "map(lambda x:x+1,xs)".
But, since this particular use doesn't avoid a function call, the map
is faster.
--
CARL BANKS
More information about the Python-list
mailing list