Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61706
| Date | 2013-12-12 13:32 +0000 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Optimizing list processing |
| References | <52a8fb2d$0$29992$c3e8da3$5496439d@news.astraweb.com> <mailman.3953.1386815228.18130.python-list@python.org> <52a9a75a$0$29992$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmqQu57xErByF6f6PtsCmq66c2M=xUQBbXZpS3A=exHcsA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3986.1386855129.18130.python-list@python.org> (permalink) |
On 12/12/2013 12:25, Chris Angelico wrote: > On Thu, Dec 12, 2013 at 11:08 PM, Steven D'Aprano > <steve+comp.lang.python@pearwood.info> wrote: >> P.S. The algorithm I'm working on is a way of generating index and rank >> tables. Not that it really matters -- what matters is determining whether >> or not to shift from "make a copy of the list" to "modify the list in >> place". > > So you're currently looking at... > > if len(table) < ?????: > table = [i for x,i in table] > else: > for x, i in table: > table[i] = x > > > Can I throw a spanner [1] in the works with other suggestions to try timing? > > table[:] = [i for x,i in table] # Does slice assignment get optimized? > [snip] If you're trying that, you could also try: table[:] = (i for x,i in table)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Optimizing list processing Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-11 23:54 +0000
Re: Optimizing list processing MRAB <python@mrabarnett.plus.com> - 2013-12-12 00:59 +0000
Re: Optimizing list processing Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-12 01:43 +0000
Re: Optimizing list processing MRAB <python@mrabarnett.plus.com> - 2013-12-12 02:09 +0000
Re: Optimizing list processing duncan smith <buzzard@invalid.invalid> - 2013-12-12 01:02 +0000
Re: Optimizing list processing Ben Finney <ben+python@benfinney.id.au> - 2013-12-12 12:18 +1100
Re: Optimizing list processing Terry Reedy <tjreedy@udel.edu> - 2013-12-11 21:26 -0500
Re: Optimizing list processing Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-12 12:08 +0000
Re: Optimizing list processing Chris Angelico <rosuav@gmail.com> - 2013-12-12 23:25 +1100
Re: Optimizing list processing MRAB <python@mrabarnett.plus.com> - 2013-12-12 13:32 +0000
Re: Optimizing list processing Chris Angelico <rosuav@gmail.com> - 2013-12-13 01:06 +1100
Re: Optimizing list processing Terry Reedy <tjreedy@udel.edu> - 2013-12-12 13:40 -0500
Re: Optimizing list processing Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-13 00:14 +0000
Re: Optimizing list processing Chris Angelico <rosuav@gmail.com> - 2013-12-13 12:01 +1100
Re: Optimizing list processing Stefan Behnel <stefan_ml@behnel.de> - 2013-12-12 12:09 +0100
Re: Optimizing list processing Peter Otten <__peter__@web.de> - 2013-12-12 16:08 +0100
Re: Optimizing list processing Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-13 03:01 +0000
Re: Optimizing list processing rusi <rustompmody@gmail.com> - 2013-12-12 21:35 -0800
Re: Optimizing list processing Terry Reedy <tjreedy@udel.edu> - 2013-12-12 13:07 -0500
csiph-web