Lazy argument evaluation (was Re: expression form of one-to-many dict?)

Nick Coghlan ncoghlan at iinet.net.au
Wed Dec 22 08:12:17 EST 2004


Steven Bethard wrote:
>> There must be something wrong with this idea that I'm missing. . .
> 
> 
> Well, it does cost you some conciceness, as your examples show[1]:
> 
> lazy(mul, x, y)                     v.s.   :x * y
> lazy(itemgetter(i), x)              v.s.   :x[i]
> lazy(attrgetter("a"), x)            v.s.   :x.a
> lazycall(lazy(attrgetter("a"), x))  v.s.   :x.a()
> 
> Not sure how I feel about this yet.  I don't personally need lazy 
> argument evaluation often enough to be able to decide which syntax would 
> really be clearer...

I think you've hit the downside on the head, though. Any time you have to use 
the operator module, you take a big hit in verbosity (particularly since noone 
ever came up with better names for attrgetter and itemgetter. . .)

There's a reason people like list comprehensions :)

Ah well, I'll let it bake for a while - I'm still not entirely sure about it 
myself, since I'm in a similar boat to you w.r.t. lazy evaluation (I usually 
just define functions that do what I want and pass them around).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list