Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'dan': 0.09; 'similar,': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; '...because': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'key)': 0.16; 'sorting': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'pointed': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'fine,': 0.31; 'probably': 0.32; 'subject:with': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'pm,': 0.38; 'good:': 0.84; 'to:none': 0.92 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:cc :content-type; bh=mbWlD3Ym9dqX6e22/3jOyHxINfmf0kWcy7ftE0lS6wk=; b=C+AXFsArKsKu+Vn3VTJC9YfzR8hqiK4pq3Ckx2W/4mlVXgV184ZIFQNo/aYwwiv1Xm UhXT1oFL3ulHvMWhNmN+RsE1cZyS0INodavMvN8kbWSrHf3xT7mspMD1miPnW76a4USU s3eo4cH2V3y1aAIZgcVh9NTKQVb3n2xEzLrQAqqQTPm34oI+pXAUXXmARSDGtwxAhPrJ Ebm4BEE1vb9IskwWmOHsSXOJ27FgUIMwNfks437rzHeiJhB2SCqWVI1Udd1UDiPBdrx3 KeGW+zXgDsiLoWmFUYqBySJ07u5ecxg2SiBgp5idNlxppDRTvz+l1cN7VfbJJ/5UOOY1 bjGw== MIME-Version: 1.0 X-Received: by 10.68.108.194 with SMTP id hm2mr100604685pbb.22.1388806736152; Fri, 03 Jan 2014 19:38:56 -0800 (PST) In-Reply-To: References: Date: Sat, 4 Jan 2014 14:38:56 +1100 Subject: Re: Creating a list with holes From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1388806739 news.xs4all.nl 2873 [2001:888:2000:d::a6]:49928 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63103 On Sat, Jan 4, 2014 at 2:32 PM, Dan Stromberg wrote: > That is fine, sorting once at then end of a script is a good use of > sorted(some_dict.keys()). However, it probably should be pointed out > that this, while similar, is not so good: > > for thing in range(n): > for key in sorted(some_dict.keys()): > do_something(thing, key) > > ...because it's sorting n times. Oh! Yeah. Yeah, that would be inefficient. ChrisA