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


Groups > comp.lang.python > #73500

Re: Are there performance concerns with popping from front of long lists vs. the end of long lists?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!rt.uk.eu.org!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.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'pop': 0.05; 'slow.': 0.09; 'container.': 0.16; 'deque': 0.16; 'ends,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'item)': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'pop()': 0.16; 'popping': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject: \n ': 0.16; 'index': 0.16; 'wrote:': 0.18; 'later': 0.20; 'header:User-Agent:1': 0.23; 'equivalent': 0.26; 'references': 0.26; 'values': 0.27; 'header :In-Reply-To:1': 0.27; 'correct': 0.29; 'moved': 0.30; 'lists?': 0.31; 'subject:end': 0.31; 'subject:the': 0.34; 'subject:from': 0.34; 'subject:with': 0.35; 'operations': 0.35; 'received:84': 0.35; 'subject:lists': 0.35; 'but': 0.35; 'words,': 0.36; 'subject:?': 0.36; 'should': 0.36; 'performance': 0.37; 'to:addr :python-list': 0.38; 'list,': 0.38; 'to:addr:python.org': 0.39; 'first': 0.61; 'therefore,': 0.64; 'subject:. ': 0.67; 'subject:there': 0.68; 'fast,': 0.84; 'popped': 0.84; 'subject:long': 0.84; 'subject:Are': 0.93
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=E5NDpMtl c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=u9EReRu7m0cA:10 a=UiWG9m4C7agA:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=9ofmAYykAAAA:8 a=BI8D3vTSm4nAgp2QtiMA:9 a=QEXdDO2ut3YA:10 a=zRA-lYGUHKoA:10
X-AUTH mrabarnett:2500
Date Sun, 22 Jun 2014 19:16:18 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Are there performance concerns with popping from front of long lists vs. the end of long lists?
References <1403460221.20360.131626817.5EFAE11B@webmail.messagingengine.com>
In-Reply-To <1403460221.20360.131626817.5EFAE11B@webmail.messagingengine.com>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
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.11190.1403460981.18130.python-list@python.org> (permalink)
Lines 13
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1403460981 news.xs4all.nl 2959 [2001:888:2000:d::a6]:45142
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73500

Show key headers only | View raw


On 2014-06-22 19:03, python@bdurham.com wrote:
> Should I have any performance concerns with the index position used
> to pop() values off of large lists?
>
> In other words, should pop(0) and pop() be time equivalent operations
>  with long lists?
>
When an item is popped from a list, all of the later items (they are
actually references to each item) are moved down. Therefore, popping
the last item is fast, but popping the first item is slow.

If you want to pop efficiently from both ends, then a deque is the
correct choice of container.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Are there performance concerns with popping from front of long lists vs. the end of long lists? MRAB <python@mrabarnett.plus.com> - 2014-06-22 19:16 +0100

csiph-web