Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63103 > unrolled thread

Re: Creating a list with holes

Started byChris Angelico <rosuav@gmail.com>
First post2014-01-04 14:38 +1100
Last post2014-01-04 14:38 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Creating a list with holes Chris Angelico <rosuav@gmail.com> - 2014-01-04 14:38 +1100

#63103 — Re: Creating a list with holes

FromChris Angelico <rosuav@gmail.com>
Date2014-01-04 14:38 +1100
SubjectRe: Creating a list with holes
Message-ID<mailman.4881.1388806739.18130.python-list@python.org>
On Sat, Jan 4, 2014 at 2:32 PM, Dan Stromberg <drsalists@gmail.com> 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web