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


Groups > comp.lang.python > #111539

Re: PEP Request: Advanced Data Structures

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: PEP Request: Advanced Data Structures
Date Sun, 17 Jul 2016 12:43:01 +1000
Lines 27
Message-ID <mailman.50.1468723384.2307.python-list@python.org> (permalink)
References <fphlobd109lvi2e4r4oe4qjpcf97chhe67@4ax.com> <20160717005426.GA50011@cskk.homeip.net> <CAPTjJmpfPBMwT5zSM43zonUht_AY2dpzqwSv53XZiX5OZMCoig@mail.gmail.com> <mailman.49.1468719034.2307.python-list@python.org> <871t2tdme3.fsf@jester.gateway.pace.com> <CAPTjJmrS84wQt-hKQyoOwZ18cKOQ84Ra5mGWNhwkaqO6OZ0EGA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de up59ycIDlt11FfiGAkyOBg7ZI6Q8xtN5NLAXvgzX80Bg==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'linear': 0.07; 'list...': 0.07; 'list?': 0.07; 'subject:PEP': 0.07; 'ugly': 0.07; 'cc:addr :python-list': 0.09; 'happen.': 0.09; 'insertion': 0.09; 'lookup': 0.09; 'pointers': 0.09; 'tracing': 0.09; 'python.': 0.11; 'language,': 0.11; 'size,': 0.13; '(when': 0.16; '2016': 0.16; 'chasing': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'massively': 0.16; 'operation,': 0.16; 'pointers.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Advanced': 0.16; 'too?': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'element': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'level,': 0.22; 'decide': 0.23; 'elements': 0.23; 'insert': 0.23; 'header:In-Reply-To:1': 0.24; 'paul': 0.24; 'example': 0.26; 'chris': 0.26; 'point.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'idea': 0.28; 'occasional': 0.29; "i'm": 0.30; 'operations': 0.31; 'up.': 0.32; 'table': 0.32; 'though,': 0.32; 'maybe': 0.33; 'list': 0.34; 'received:google.com': 0.35; 'something': 0.35; "isn't": 0.35; 'item': 0.35; 'but': 0.36; 'list,': 0.36; 'there': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'list.': 0.37; 'doing': 0.38; 'difference': 0.38; 'front': 0.38; 'delete': 0.38; 'mean': 0.38; 'goes': 0.39; 'sure': 0.39; 'does': 0.39; 'where': 0.40; 'some': 0.40; 'your': 0.60; 'bring': 0.62; 'linked': 0.63; 'relatively': 0.63; 'more': 0.63; 'benefit': 0.66; 'subject:Data': 0.66; 'costs': 0.67; 'jul': 0.72; 'search,': 0.72; 'chrisa': 0.84; 'costly': 0.84; 'damaged': 0.84; 'to:none': 0.91; 'cost,': 0.91; 'surgery': 0.91; 'overall,': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc; bh=Mcmim6cOMJ2tbhl+lLohVgfE/O5+ujvuyDido1BGIjU=; b=MrCXO7qqaWSn7qWK+9Mx0ngEVFXEa0WwOxm8hAJAkQ5aV1xfKyW8pri3Kb61ybTJkz Myau8aab+enF70fdueZOVb8dP8BJLqTppt+/ppkH/u/XpsKBxqVwkM9pwZrpQ+bOe2RM 3swfBnCTIHQ+L0pEgGVbWVf7cnfyZ1XXUm+K/QjXTziZOVHKZKkYC53PHmhQKDB0V5GV /PVlCovweASH0pwc0yOuVSWZE4+JGu3SHwz54v/oeoIQPB+fovwqoIjF4/NMXXz+bEJe qt2yfcoRiqDTQXa7k+8q32PhzifM4NxU56Kd5c9KWW/stG1qESX5a07fU75T5o5Lr05n Gn+g==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=Mcmim6cOMJ2tbhl+lLohVgfE/O5+ujvuyDido1BGIjU=; b=nAvfWkZoQ/3C+DFHcszuoNn6rR0EVBNr/1QoWU/aVJDHtx71ChmC2THI3TPPBuopXH C0a2vgGh99Bc+PUFUGuurfSwg1wdYVXyJOQ6l2UoAb81pGptmwiqwkmBiAhq92lcvggH J/VrG/+61vTUyCb1OzhALITXI+UOKqahFa6zEtBMF+pP3Gn6Sh6pn3gofvQxfgtDLZks CQ07Jt+Hm3BayOeL4giq0wshXhgpWzgWgsgBqIq2/Q3XS49xvLhby6jRbyH0W2n+h3Ks rXrIMGDcRIjkOcVg8Htmf4NRbasgWgOK/M/npFz44AWI5xKw97q3p8UXIWBqlBuu5/D8 +6VQ==
X-Gm-Message-State ALyK8tL7N4ApORuuBmKYJBlBkErefgbI9b7cWE8AE5C6fI85T5FRDgRbMlSINq3LWKcvKbao6Wevxe74wGmHKw==
X-Received by 10.194.117.72 with SMTP id kc8mr6281186wjb.30.1468723382583; Sat, 16 Jul 2016 19:43:02 -0700 (PDT)
In-Reply-To <871t2tdme3.fsf@jester.gateway.pace.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
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>
X-Mailman-Original-Message-ID <CAPTjJmrS84wQt-hKQyoOwZ18cKOQ84Ra5mGWNhwkaqO6OZ0EGA@mail.gmail.com>
X-Mailman-Original-References <fphlobd109lvi2e4r4oe4qjpcf97chhe67@4ax.com> <20160717005426.GA50011@cskk.homeip.net> <CAPTjJmpfPBMwT5zSM43zonUht_AY2dpzqwSv53XZiX5OZMCoig@mail.gmail.com> <mailman.49.1468719034.2307.python-list@python.org> <871t2tdme3.fsf@jester.gateway.pace.com>
Xref csiph.com comp.lang.python:111539

Show key headers only | View raw


On Sun, Jul 17, 2016 at 12:33 PM, Paul Rubin <no.email@nospam.invalid> wrote:
> Chris Angelico <rosuav@gmail.com> writes:
>>> keep a reference to an element deep in the list, and insert a new
>>> element in O(1) time at that point.
>> at the C level, wouldn't tracing the links cost massively more than
>> the occasional insertion too? I'm not sure O(1) is of value at any
>> size, if the costs of all your other operations go up.
>
> I think the idea is that you're already deep in the list when you decide
> to insert an element or do other surgery on the list.  An example might
> be a lookup table with linear search, where you want to bring the LRU
> item to the front of the list after finding it.  Really though, that's
> an ugly thing to be doing in any language, and it definitely isn't
> something that comes up much in Python.

Right, but how did you *get* that deep into the list? By following a
chain of pointers. That's a relatively costly operation, so the
benefit of not having to move all the following elements is damaged
some by the cost of chasing pointers to get there in the first place.
So overall, performance would be better with the high-performance
list, even if it does mean moving a bunch of elements (when you delete
some). Since it's a difference in asymptotic cost, there would
theoretically be some number of elements after which it would be
cheaper to use the linked list... but maybe the cost of chasing
pointers goes up even more, to make that never happen.

ChrisA

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


Thread

Re: PEP Request: Advanced Data Structures Chris Angelico <rosuav@gmail.com> - 2016-07-17 11:30 +1000
  Re: PEP Request: Advanced Data Structures Paul Rubin <no.email@nospam.invalid> - 2016-07-16 19:33 -0700
    Re: PEP Request: Advanced Data Structures Chris Angelico <rosuav@gmail.com> - 2016-07-17 12:43 +1000
    Re: PEP Request: Advanced Data Structures MRAB <python@mrabarnett.plus.com> - 2016-07-17 03:49 +0100

csiph-web