[Tutor] First code snipet
Alan Gauld
alan.gauld at btinternet.com
Sun Jul 26 14:53:15 CEST 2009
"Dave Angel" <davea at ieee.org> wrote
> len() is very fast, so there's no need for a separate variable to keep
> track of the lengths of inpile1 and inpile2. So eliminate all refs to
> pile1c and pile2. In the while, just use
> while len(inpile1) and len(inpile2):
Or even simpler:
while inpile1 and inpile2:
An empty list is false too.
> pop(0) is slow, compared with pop(-1).
I didn't know that, but timing seems to suggest about 50% slower.
Interesting.
Alan G.
More information about the Tutor
mailing list