Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'elements.': 0.07; 'pypy': 0.07; 'linear': 0.09; 'slices': 0.09; "wouldn't": 0.14; '>>': 0.16; 'wrote:': 0.18; 'seems': 0.21; '>>>': 0.22; 'email addr:gmail.com>': 0.22; '>>>': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'subject:time': 0.33; 'could': 0.34; 'case,': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'e.g.': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'deleting': 0.60; '2015': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=/yYzfNy1lw+fbkmY928qN4A3qwFCQuB1VyoXgbu7OnI=; b=TMoCGbSv88g7qNBoGoSe2DCN+wQPH0HRQAvMI7kbT/l1KZOuphAOySBcNz9usbbTXn 2SApSogrCRKWYlDOUpUvjO8MnyenEZIzkmVlRAuE4zm3acBBiqRU1d0ugkuem6DBs8U4 qyiPoORQfTFS8sC5afg1zvOdsnEnWewaU+M+j6tr3SUgSFyfJm9TAVoO7hlIqkGhSRUH Krjx8hsvTtrZGxaViMCUILc3frlEFvQdzAHfuKYJW1ihcZH3rscOI84+IK3oosnl8ZIb 7ODqdODdRLvXTShL6YrZ6pNmkWHZNd8HhTcH+bOkHukxNSvH2xXe9HE0iA6fi+LkoTnE JkiA== MIME-Version: 1.0 X-Received: by 10.50.138.70 with SMTP id qo6mr21727915igb.15.1432048548644; Tue, 19 May 2015 08:15:48 -0700 (PDT) In-Reply-To: References: <9ceklad15llnv3npejq9iuh91soci8aeqo@4ax.com> <555b0621$0$2753$c3e8da3$76491128@news.astraweb.com> Date: Tue, 19 May 2015 09:15:48 -0600 Subject: Re: Slices time complexity From: Ian Kelly To: Python Content-Type: multipart/alternative; boundary=001a1134bbc60b0ead051670c91d X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432048556 news.xs4all.nl 2909 [2001:888:2000:d::a6]:43216 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90862 --001a1134bbc60b0ead051670c91d Content-Type: text/plain; charset=UTF-8 On May 19, 2015 4:16 AM, "Serhiy Storchaka" wrote: > > On 19.05.15 12:45, Steven D'Aprano wrote: >> >> On Tuesday 19 May 2015 05:23, Mario Figueiredo wrote: >>> >>> From the above link it seems slices work in linear time on all cases. >> >> >> I wouldn't trust that is always the case, e.g. deleting a contiguous slice >> from the end of a list could be O(1). > > > It always has linear complexity. You need to decref removed elements. Only in CPython. The operation might be O(1) in Pypy or Jython. --001a1134bbc60b0ead051670c91d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On May 19, 2015 4:16 AM, "Serhiy Storchaka" <storchaka@gmail.com> wrote:
>
> On 19.05.15 12:45, Steven D'Aprano wrote:
>>
>> On Tuesday 19 May 2015 05:23, Mario Figueiredo wrote:
>>>
>>> =C2=A0From the above link it seems slices work in linear time = on all cases.
>>
>>
>> I wouldn't trust that is always the case, e.g. deleting a cont= iguous slice
>> from the end of a list could be O(1).
>
>
> It always has linear complexity. You need to decref removed elements.<= /p>

Only in CPython. The operation might be O(1) in Pypy or Jyth= on.

--001a1134bbc60b0ead051670c91d--