Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'skip:` 10': 0.07; 'subject:Question': 0.07; 'append': 0.09; 'python': 0.11; 'curious.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:`': 0.16; 'wrote:': 0.18; 'items.': 0.19; 'memory': 0.22; 'header :User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; '(which': 0.31; 'there,': 0.34; 'received:84': 0.35; 'hi,': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'space': 0.40; 'entire': 0.61; 'first': 0.61; 'more': 0.64; 'saving': 0.69; 'moves': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=JLW1sq6b c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=sASEtNAQL0YA:10 a=kJY7XzBcQnsA:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=Hyd6ySMz3VIA:10 a=13qPfq1VjAUymNIuMDgA:9 a=QEXdDO2ut3YA:10 a=3r3Oin348ScA:10 a=3VGXJNSaQs4A:10 X-AUTH: mrabarnett:2500 Date: Fri, 07 Feb 2014 00:42:04 +0000 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Question about `list.insert` References: <4041bba7-91bc-4803-9150-2fcf14ecb5a9@googlegroups.com> In-Reply-To: <4041bba7-91bc-4803-9150-2fcf14ecb5a9@googlegroups.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 10 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391733726 news.xs4all.nl 2866 [2001:888:2000:d::a6]:51638 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65568 On 2014-02-06 23:59, cool-RR wrote: > Hi, > > I'm curious. If I append an item to a list from the left using > `list.insert`, will Python always move the entire list one item to > the right (which can be super-slow) or will it check first to see > whether it can just allocate more memory to the left of the list and > put the item there, saving a lot of resources? > If it needs more space it resizes. It then moves the items.