Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63103
| References | <CACwCsY5P47-dB1NLQTUTQ=0aF6B+-M3y4hCxcUGmcVmHM8=-xQ@mail.gmail.com> <CAPTjJmp+NtGYWE3S3SGjo-xoYC74Exdpci_+x4AUNgqM5=CJNQ@mail.gmail.com> <CAGGBd_ooeJLsW_eoEBbrbiv9zxm_75bvWnO1U8JEj8xOnNwMfQ@mail.gmail.com> <CAPTjJmrbXLQP9gYwpzjQta6Mn78gDBQ39vFfsi7R7+42pMxeCw@mail.gmail.com> <CAGGBd_pu97KPKmSMq0=oG_yU-rGPdfCASJr-Pj9Nk7gA2A47Zw@mail.gmail.com> |
|---|---|
| Date | 2014-01-04 14:38 +1100 |
| Subject | Re: Creating a list with holes |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4881.1388806739.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Creating a list with holes Chris Angelico <rosuav@gmail.com> - 2014-01-04 14:38 +1100
csiph-web