On 11/6/06, Jonathan Ellis <[EMAIL PROTECTED]> wrote:
Only in the special case of the function you are mapping being
implemented in C. Otherwise, a list comprehension will be (slightly)
faster as well as more readable.
-Jonathan
Everything in the lambda is a built-in operator in python, implemented
in C. I incorrectly thought that anonymous functions in python were
also implemented in the C-compiled code. I was wrong. But that poor
assumption led to the rest of the code. By using the lambda I
basically forced myself to try and get it working in a single
statement. Thus the use logical operators for conditionals, rely on
the TypeError for ealy exit.
However, everything in the lambda is a built-in operator in python,
implemented in C. So if I had been correct, the meat of the program,
except for the try and except statements, would have run in C rather
than in the python interpreter. Had I known that lambdas aren't
implemented in C I would have done this differently, defined my own
function and exception for an early exit.
Oh well, lesson learned. Don't post hacked up code to plug, no matter
how trivial, or people may call for your execution. :)
Dan
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/