Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61648
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.051 |
| X-Spam-Evidence | '*H*': 0.90; '*S*': 0.00; 'mrab': 0.05; 'bug.': 0.09; 'indexes': 0.09; 'modulo': 0.09; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'looks': 0.24; 'header:In-Reply-To:1': 0.27; 'dec': 0.30; 'subject:list': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'bugs': 0.33; 'copying': 0.34; 'table': 0.34; 'doing': 0.36; 'example,': 0.37; 'wrong': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'introduced': 0.61; "you're": 0.61; 'further': 0.61; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'compare:': 0.84; 'pasting': 0.84; 'reply-to:addr:python.org': 0.84; '2013': 0.98 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=C6LQl2/+ c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=OJn0C7AadrgA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=iG_8WwV8i_QA:10 a=VvIsvGqJuPikpMdUE-sA:9 a=wPNLvfGTeEIA:10 |
| X-AUTH | mrabarnett:2500 |
| Date | Thu, 12 Dec 2013 02:09:42 +0000 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Optimizing list processing |
| References | <52a8fb2d$0$29992$c3e8da3$5496439d@news.astraweb.com> <mailman.3942.1386809980.18130.python-list@python.org> <52a914c3$0$29992$c3e8da3$5496439d@news.astraweb.com> |
| In-Reply-To | <52a914c3$0$29992$c3e8da3$5496439d@news.astraweb.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | python-list@python.org |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3951.1386814181.18130.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1386814181 news.xs4all.nl 2862 [2001:888:2000:d::a6]:35029 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:61648 |
Show key headers only | View raw
On 12/12/2013 01:43, Steven D'Aprano wrote: > On Thu, 12 Dec 2013 00:59:42 +0000, MRAB wrote: > >>> table = [(x, i) for i,x in enumerate(iterable)] >>> table.sort() >> >> This looks wrong to me: >> >>> for x, i in table: >>> table[i] = x > > Yes, you're right, I over-simplified the example, and in doing so > introduced a bug. What I actually use is: > > for i, x in enumerate(table): > table[i] = x[1] > > modulo any further bugs introduced while copying and pasting :-) > How does this compare: table = list(iterable) indexes = list(range(len(table))) indexes.sort(key=table.__getitem__)
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