$10K coding deathmatch
dbstovall at gmail.com
Mon Nov 6 15:19:42 MST 2006
On 11/6/06, Jonathan Ellis <jonathan at carnageblender.com> 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.
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. :)
More information about the PLUG