Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.031 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'elements.': 0.05; '21,': 0.07; 'interpreted': 0.07; 'python': 0.09; 'executes': 0.09; 'subject:method': 0.09; 'language': 0.14; '(but': 0.15; '"it\'s': 0.16; ':-).': 0.16; 'adam': 0.16; 'algorithmic': 0.16; 'beautifully': 0.16; 'chris,': 0.16; 'fond': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:Problem': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'instance,': 0.17; 'saying': 0.18; 'code.': 0.20; 'received:209.85.214.174': 0.21; 'beauty': 0.22; 'second': 0.24; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'am,': 0.27; 'scale': 0.27; 'important.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'unlikely': 0.29; 'code': 0.31; 'problem.': 0.32; 'comments': 0.33; 'purposes,': 0.33; 'zero': 0.33; 'handle': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; '(with': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'nov': 0.35; 'problem,': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'subject:with': 0.36; 'should': 0.36; 'thank': 0.36; 'uses': 0.37; 'being': 0.37; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'most': 0.61; 'time,': 0.62; 'worth': 0.63; 'ever': 0.63; 'skip:n 10': 0.63; 'more': 0.63; 'making': 0.64; 'dear': 0.66; 'bulk': 0.78; 'absolutely': 0.84; 'alvaro': 0.84; 'combo': 0.84; 'details...': 0.84; 'is!': 0.84; 'newcomer': 0.84; 'ridiculously': 0.84; 'inefficient': 0.91; 'poorly': 0.93; 'technique': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=dFPIAJpRypGKJ6ggpcFfz4kutEDeAnJJRlyeZtDkI2U=; b=pVhN9giOa/v8btr+/LIAm0Lq/EVFWxsVVKv28CblTpJ/brL9Ee9HhPn4S9V240aGxU 8fhkLsBmj5Go0PxD6GsmtabfRFvs6BskWnAYZJCGrEfPbTHiumsOuwLVjCEH9wxXKM6v VnapqKlQOxKFEHx2P68d5WciG1m1lm8m8jCm4eIVsWg1QBarO5IskswD8qLjqgP8X/Qs tOCK0jUeiyn50/MSnMrtLfIdHKKC8QENsVN/CPz7j+KqVbVwGX6n8LYEWHc0IUx/xp1F kYiCyOFFbMPbHnEuVg5SCzpUU+PGPiTPpR+sBhUjcGcsB3gS14bGp1i95TJPrmKr8U/O JMzg== MIME-Version: 1.0 In-Reply-To: <9caaea9c-8b7c-4ed5-bc3b-2519a58ceb26@googlegroups.com> References: <9caaea9c-8b7c-4ed5-bc3b-2519a58ceb26@googlegroups.com> Date: Wed, 21 Nov 2012 07:48:08 +1100 Subject: Re: Problem with list.remove() method From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353444493 news.xs4all.nl 6903 [2001:888:2000:d::a6]:59045 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33657 On Wed, Nov 21, 2012 at 1:37 AM, Alvaro Combo 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! ChrisA