Dot product?

David C. Ullrich ullrich at math.okstate.edu
Mon Dec 13 13:42:32 EST 1999


Greg Ewing wrote:

> "David C. Ullrich" wrote:
> >
> > but it doesn't look right -
> > seems like the Python way would involve a "for x in X"
> > instead of that "for j in range(len(X))".
>
> Sadly, that *is* the current Python idiom for doing parallel
> iteration without incurring the overhead of constructing an
> intermediate object.

    Right.

> List comprehensions won't change this, unless whatever flavour
> of them we get includes a syntax for parallel iteration -- in
> which case the normal "for" loop will probably get it as well.

    As long as I'm asking stupid questions, what would
"list comprehension" be?

> My preferred backward-compatible candidate for this is:
>
>    for x and y in list1, list2:
>       ...
>
> Greg




More information about the Python-list mailing list