Since the tuples are sorted, you can simply find the first tuple with a value less than the threshold, and then delete the remaining values ββusing the slice notation:
index = next(i for i, (t1, t2) in enumerate(myTup) if t2 < threshold) del myTup[index:]
According to Vaughn Cato, binary search will accelerate even more. bisect.bisect would be useful, except that it would not work with your current data structure unless you create a separate key sequence as described here . But this violates your ban on creating new lists.
However, you can use the source code as the basis for your own binary search. Or you can change your data structure:
>>> myTup [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e'), (5, 'f'), (6, 'g'), (7, 'h'), (8, 'i'), (9, 'j')] >>> index = bisect.bisect(myTup, (threshold, None)) >>> del myTup[:index] >>> myTup [(6, 'g'), (7, 'h'), (8, 'i'), (9, 'j')]
The disadvantage is that deletion can occur over linear time, since Python will have to move the entire memory block back ... unless Python is smart about deleting fragments starting at 0 . (Somebody knows?)
Finally, if you really want to change the data structure, you can do this:
[(-9, 'a'), (-8, 'b'), (-7, 'c'), (-6, 'd'), (-5, 'e'), (-4, 'f'), (-3, 'g'), (-2, 'h'), (-1, 'i'), (0, 'j')] >>> index = bisect.bisect(myTup, (-threshold, None)) >>> del myTup[index:] >>> myTup [(-9, 'a'), (-8, 'b'), (-7, 'c'), (-6, 'd')]
(Note that Python 3 will complain about comparing None , so instead you can use something like (-threshold, chr(0)) .)
My suspicion is that the linear time search, which I suggested at the beginning, is acceptable in most cases.