Newbie ?:A more concise way?
Carel Fellinger
cfelling at iae.nl
Mon Mar 4 18:52:21 EST 2002
Brian <brian at lodoss.org> wrote:
> Carel Fellinger <cfelling at iae.nl> wrote in message news:<a5um79$ict$1 at animus.fel.iae.nl>...
>> >>> class MyClass: pass
>> >>> z = map(lambda x: C(), range(3))
...
> I'm happy with the performance of the expression too; I'm using a
> similar map expression as an argument to Numeric.array() now and it
> works very well for me.
If it's performance and not code obfuscation you're after, maybe you'd
better spent some time on profiling it.
My gut feelings (and those are usualy wrong:) tell my to fear the lambda
here as it introduces an extra function call (expensive in Python) for
each instance to be made.
--
groetjes, carel
More information about the Python-list
mailing list