Dot-comma, anyone? (Re: zip or marry etc)

Michael Hudson mwh21 at cam.ac.uk
Fri Jul 21 02:48:06 EDT 2000


Greg Ewing <see at my.signature> writes:

> Michael Hudson wrote:
> > 
> > > an elementwise tuple-creation operator
> > 
> > You're joking, right?
> 
> About that particular syntax, yes. But not about
> the idea of some sort of zipping syntax.
> 
> For one thing, it would make it easier to implement
> parallel iteration efficiently. When I write
> 
>   for x,y in zip(a,b):
> 
> I'm just trying to express the way the iteration is
> to be carried out. I don't really mean that I want the
> zip of the two lists to be computed first and then
> iterated over.
> 
> If there were a special syntax for zipping, the
> compiler could easily recognise this case and
> optimise it.

Mmm.  I *think* (and it's only thinking) that concerns for efficiency
here are a little misplaced; I mean

for i in range(len(l)):
    print i, l[i]

is hardly efficient either, but I'd still wager that execution time
for the loop body thoroughly dominates the overhead of the list
construction (you have to take trips around the interpreter loop in
ceval.c for one thing).

> I haven't thought of a syntax for it that I really
> like, yet, though. 

Yeah, and as you said in another post, the n-ary nature of the
operation is going to make that tricky.

Cheers,
M.

-- 
  If you don't use emacs, you're a pathetic, mewling, masochistic
  weakling and I can't be bothered to convert you.    -- Ron Echeverri



More information about the Python-list mailing list