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


Groups > comp.lang.python > #61706

Re: Optimizing list processing

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'algorithm': 0.04; 'assignment': 0.07; 'try:': 0.09; 'determining': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'list"': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'table)': 0.16; 'throw': 0.16; 'index': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'thu,': 0.19; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; '[1]': 0.29; 'dec': 0.30; 'subject:list': 0.30; "i'm": 0.30; "d'aprano": 0.31; 'steven': 0.31; 'table': 0.34; 'could': 0.34; 'really': 0.36; 'list': 0.37; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'does': 0.39; '12,': 0.39; 'generating': 0.39; 'to:addr:python.org': 0.39; "you're": 0.61; 'p.s.': 0.66; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'reply-to:addr:python.org': 0.84; 'rank': 0.93; '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=baqLi5_GPZIA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=iG_8WwV8i_QA:10 a=kZ7UWmmPAAAA:8 a=SUQkbTY-2LKf96MRdEwA:9 a=wPNLvfGTeEIA:10 a=pyH5b1fOeEsA:10
X-AUTH mrabarnett:2500
Date Thu, 12 Dec 2013 13:32:11 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
MIME-Version 1.0
To python-list@python.org
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>
In-Reply-To <CAPTjJmqQu57xErByF6f6PtsCmq66c2M=xUQBbXZpS3A=exHcsA@mail.gmail.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.3986.1386855129.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386855129 news.xs4all.nl 2860 [2001:888:2000:d::a6]:55858
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61706

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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