How to del item of a list in loop?

Nick Coghlan ncoghlan at
Sun Jan 16 12:05:59 CET 2005

John Machin wrote:
> Nick Coghlan wrote:
>>The effbot's version is still going to be faster though:
>>   lst = [x for x in lst if x != 2]
> Have you measured this?

Nope. I'm going purely on the fact that it is O(n), and the in-place 
modification will always be worse than that.


Nick Coghlan   |   ncoghlan at   |   Brisbane, Australia

More information about the Python-list mailing list