> def lowest(s1,s2):
>     s = ""
>     for c1,c2 in [x for x in zip(s1,s2)]:
>         s += lowerChar(c1,c2)
>     return s
>
> but it's hardly any more elegant than using a loop counter, and I'm
> guessing it's performance is a lot worse - I assume that the zip
> operation is extra work?
>
> Iain

Always look in itertools for stuff like this:

http://docs.python.org/lib/itertools-functions.html#l2h-1392

for c1, c2 in itertools.izip(s1, s2):
    ...

I haven't profiled it, but it makes sense that this would be fast.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to