> I'm processing a stream of N numbers and want to keep track of the K > largest. There's too many numbers in the stream (i.e. N is too large) > to keep in memory at once. K is small (100 would be typical). > ...
deque can be bounded by maxsize, might fit the bill: >>> from collections import deque >>> d = deque([], 3) >>> for i in range(10): d.append(i) >>> d deque([7, 8, 9], maxlen=3) >>> HTH, -- Miki -- http://mail.python.org/mailman/listinfo/python-list