Problem with list.remove() method

Chris Angelico rosuav at
Tue Nov 20 21:48:08 CET 2012

On Wed, Nov 21, 2012 at 1:37 AM, Alvaro Combo <alvaro.combo at> wrote:
> Dear Chris,
> Thank you very much for you reply...
> For a newcomer to Python the Hell is in the details... :-).

You're most welcome! As Adam Savage of Mythbusters is fond of saying
(with an exaggerated accent), "It's all a learning experience".

> Regarding you other (most relevant) comments, I absolutely agree... BUT in those cases... I was aware :-). But since it is in fact an exercise... and having N^2 operations... is not important. Still your comments are quite pertinent.

Yep. O(N^2) isn't inherently a problem, it just means that the
technique will scale poorly to large numbers of list elements. With
small lists, it'll be "fast enough" - for all intents and purposes,
the bulk of Python code executes in zero time, despite being in an oh
so slow interpreted language and using ridiculously inefficient (but
beautifully readable) code. That's the beauty of modern hardware :)

However, I do think that people should be aware when they're writing
non-scaleable code. That's not just algorithmic complexity; if you're
making a system that won't handle more than one request a second
(because, for instance, it uses seconds-since-1970 as a request
identifier), that's something worth being aware of, even if it's
unlikely ever to be a problem. Just know, so that if a problem ever
_does_ occur, you know where it is!


More information about the Python-list mailing list