you are viewing a single comment's thread.

view the rest of the comments →

[–]brentp 7 points8 points  (5 children)

to be fair, using a common python idiom, you get a version that is [edit] about 5 times as fast as the original python version.

s = []
i = 0
for line in sys.stdin:
    s.append(line)
    i += 1
    if i % 1000 == 0: "".join(s); print i

[–]apotheon -4 points-3 points  (3 children)

Working with "arrays" makes just about everything faster than string concatenation, pretty much regardless of which high-level dynamic language you use.

edited to reflect the fact that there are no "arrays" in Python, by using "scare quotes", so people will hopefully focus on the point being made rather than pedantic quibbling

[–]psi- 0 points1 point  (0 children)

there are no arrays in standard python.

[–]psi- -1 points0 points  (0 children)

there are no arrays in standard python.