Re: Need an identity operator because lambda is too slow

2007-02-18 Thread Gabriel Genellina
En Sun, 18 Feb 2007 23:31:53 -0300, Sean McIlroy <[EMAIL PROTECTED]> escribió: > On Feb 17, 9:59 pm, "Deron Meranda" <[EMAIL PROTECTED]> wrote: > [snip] > > this may be really dense, but i'm curious what's wrong with the > "multiplexer" idiom: > > for item in some_sequence: > item2 = (no

Re: Need an identity operator because lambda is too slow

2007-02-18 Thread Sean McIlroy
On Feb 17, 9:59 pm, "Deron Meranda" <[EMAIL PROTECTED]> wrote: [snip] this may be really dense, but i'm curious what's wrong with the "multiplexer" idiom: for item in some_sequence: item2 = (not some_rare_condition and item) or \ (some_rare_condition and some_transform_fun

Re: Need an identity operator because lambda is too slow

2007-02-18 Thread David Wahler
On Feb 18, 5:59 am, "Deron Meranda" <[EMAIL PROTECTED]> wrote: > Consider a much-simplified example of such an iteration where > sometimes you need to transform an item by some function, but most of > the time you don't: > > if some_rare_condition: > func = some_transform_function >

Re: Need an identity operator because lambda is too slow

2007-02-18 Thread Steven D'Aprano
On Sat, 17 Feb 2007 22:19:41 -0800, Raymond Hettinger wrote: > [Deron Meranda >>] I'm looking for something in >> Python which would act like an identity operator, or I-combinator: a >> do-nothing function. The best I know of is: (lambda x: x), but it is >> not ideal. > > File a feature reques

Re: Need an identity operator because lambda is too slow

2007-02-17 Thread Steven D'Aprano
On Sat, 17 Feb 2007 21:59:18 -0800, Deron Meranda wrote: > Consider a much-simplified example of such an iteration where > sometimes you need to transform an item by some function, but most of > the time you don't: > > if some_rare_condition: > func = some_transform_function > els

Re: Need an identity operator because lambda is too slow

2007-02-17 Thread Raymond Hettinger
[Deron Meranda >] I'm looking for something in > Python which would act like an identity operator, or I-combinator: a > do-nothing function. The best I know of is: (lambda x: x), but it is > not ideal. File a feature request on SourceForge and assign to me. This has come up a couple of times a

Re: Need an identity operator because lambda is too slow

2007-02-17 Thread Paul Rubin
"Deron Meranda" <[EMAIL PROTECTED]> writes: > do_transform = some_rare_condition > for item in some_sequence: > if do_transform: > item2 = transform_function(item) > else: > item2 = item > . # more stuff This might be a little more direct