4 ms·
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
by pdonis 13y 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.
- thomasahle 13y agoTwo loops are still linear as long as they are not nested ;-)
- pdonis 13y agoOops, yes, good point. :)