Nicko <usenet at nicko.org> writes: > # The next line is order O(n) in the number of chunks > (line, fileindex) = min(mergechunks) You should use the heapq module to make this operation O(log n) instead.