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


Groups > comp.lang.python > #111543

Re: PEP Request: Advanced Data Structures

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From cs@zip.com.au
Newsgroups comp.lang.python
Subject Re: PEP Request: Advanced Data Structures
Date Sun, 17 Jul 2016 13:27:09 +1000
Lines 43
Message-ID <mailman.53.1468727855.2307.python-list@python.org> (permalink)
References <CAPTjJmrS84wQt-hKQyoOwZ18cKOQ84Ra5mGWNhwkaqO6OZ0EGA@mail.gmail.com> <20160717032709.GA61131@cskk.homeip.net>
Reply-To python-list@python.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
X-Trace news.uni-berlin.de hOUqEh1ZOFKt1bGkz1FRSQMo5Lj1DX7BSWxvAxLSMFsg==
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'linear': 0.07; 'list?': 0.07; 'subject:PEP': 0.07; 'ugly': 0.07; 'cc:addr:python-list': 0.09; 'insertion': 0.09; 'item,': 0.09; 'lookup': 0.09; 'pointers': 0.09; 'tracing': 0.09; 'python.': 0.11; 'language,': 0.11; 'size,': 0.13; 'applies': 0.15; '2016': 0.16; '>on': 0.16; 'chasing': 0.16; 'fits': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'list)': 0.16; 'massively': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'nodes': 0.16; 'operation,': 0.16; 'pointers.': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:io': 0.16; 'received:optusnet.com.au': 0.16; 'received:psf.io': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'strength': 0.16; 'subject:Advanced': 0.16; 'too?': 0.16; 'tuple,': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'case.': 0.18; 'element': 0.18; 'refers': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'assuming': 0.22; 'level,': 0.22; 'new,': 0.22; 'cheers,': 0.22; 'decide': 0.23; 'elements': 0.23; 'insert': 0.23; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; 'paul': 0.24; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'example': 0.26; 'chris': 0.26; 'point.': 0.27; 'idea': 0.28; 'for,': 0.29; 'node': 0.29; 'occasional': 0.29; 'value)': 0.29; "i'm": 0.30; 'anywhere': 0.30; 'operations': 0.31; 'core': 0.32; 'up.': 0.32; 'table': 0.32; 'though,': 0.32; 'point,': 0.33; 'received:com.au': 0.33; 'similar': 0.33; 'structure': 0.34; 'list': 0.34; 'done': 0.35; 'something': 0.35; "isn't": 0.35; 'item': 0.35; 'but': 0.36; 'too': 0.36; 'list,': 0.36; 'there': 0.36; 'basic': 0.36; 'depends': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'charset:us-ascii': 0.37; 'list.': 0.37; 'things': 0.38; 'doing': 0.38; 'front': 0.38; 'no,': 0.38; 'stuff': 0.38; 'data': 0.39; 'sure': 0.39; 'enough': 0.39; 'where': 0.40; 'from:no real name:2**0': 0.60; 'your': 0.60; 'address': 0.61; 'bring': 0.62; 'here.': 0.62; 'linked': 0.63; 'relatively': 0.63; 'more': 0.63; 'great': 0.63; 'benefit': 0.66; 'cameron': 0.66; 'subject:Data': 0.66; 'header:Reply-To:1': 0.67; 'costs': 0.67; 'reply-to:no real name:2**0': 0.71; 'jul': 0.72; 'search,': 0.72; 'costly': 0.84; 'damaged': 0.84; 'reply- to:addr:python.org': 0.84; 'surgery': 0.91
Content-Disposition inline
In-Reply-To <CAPTjJmrS84wQt-hKQyoOwZ18cKOQ84Ra5mGWNhwkaqO6OZ0EGA@mail.gmail.com>
User-Agent Mutt/1.5.24 (2015-08-30)
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.1 cv=EfU1O6SC c=1 sm=1 tr=0 a=kPLexIa+XrsL4mdc8kxeNA==:117 a=kPLexIa+XrsL4mdc8kxeNA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=cAmyUtKerLwA:10 a=pGLkceISAAAA:8 a=vrnE16BAAAAA:8 a=crdAycUOHOYIcYRqIGkA:9 a=uVVcDGVzDR642t_H:21 a=tBdt2NNRqYmqYOt-:21 a=CjuIK1q_8ugA:10 a=nz1x9PTgaTwA:10 a=6kGIvZw6iX1k4Y-7sg4_:22 a=D4O83h6meWPcCEhhlUO6:22
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 <20160717032709.GA61131@cskk.homeip.net>
X-Mailman-Original-References <CAPTjJmrS84wQt-hKQyoOwZ18cKOQ84Ra5mGWNhwkaqO6OZ0EGA@mail.gmail.com>
Xref csiph.com comp.lang.python:111543

Show key headers only | View raw


On 17Jul2016 12:43, Chris Angelico <rosuav@gmail.com> wrote:
>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.

No, you're assuming too much here. Consider:

  LL = LinkedList()
  item = LL.insert( (some, tuple, value) )
  ... do lots of stuff with the list ...
  ... now item refers to something that might be anywhere ...
  item.add_after( (context, for, a, new, item, in , the, list) )
  ...

and any number of other scenarios of similar nature: note a node in the list 
and get to done things at or near that node at an arbirary other time.

This applies to _any_ graph like data structure where nodes would have to be 
found by traversal.

Anyway, I'm not arguing that Pythons basic list type doesn't address a great 
many needs. I'm arguing that no one size fits all. The core strength of a 
linked list is O(1) insertion at any point, provided you have a reference to 
that point. Whether that is enough benefit depends on the use case.

Cheers,
Cameron Simpson <cs@zip.com.au>

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


Thread

Re: PEP Request: Advanced Data Structures cs@zip.com.au - 2016-07-17 13:27 +1000

csiph-web