Hacker News new | ask | show | jobs
by pdonis 4667 days ago
Does join scan the entire input to know the exact size and allocate that at the start?

No, because that would make the algorithm quadratic again (one loop for the scan, second loop for the concatenation), and the whole point of the join idiom, as recommended by the Python documentation, is to avoid a quadratic algorithm.

1 comments

Two loops are still linear as long as they are not nested ;-)
Oops, yes, good point. :)