Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111528
| Path | csiph.com!news.swapon.de!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 08:45:12 +1000 |
| Lines | 45 |
| Message-ID | <mailman.43.1468709115.2307.python-list@python.org> (permalink) |
| References | <21fcec53-cf5b-4529-9790-63a1c46f534b@googlegroups.com> <CAPTjJmpQk9SwLRct-WpZMywFFLhX3A459eNzB5eHGVFyhBiDoA@mail.gmail.com> <mailman.42.1468707584.2307.python-list@python.org> <7af57bf9-72d7-4d0f-8db4-3ea02d701a5f@googlegroups.com> <CAPTjJmp2Bog+raRYVn+3GyjfLXY8=abEpVCCevjVB353DquNLQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de xzxtJPoIu8mXGi8XAWqyNAlS0g+kNuM8BBp6hgyZN41A== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.026 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'cpython': 0.05; 'scaling': 0.07; 'subject:PEP': 0.07; 'cc:addr:python-list': 0.09; 'messing': 0.09; 'def': 0.13; '(but': 0.15; '2016': 0.16; 'chris,': 0.16; 'development:': 0.16; 'education:': 0.16; 'efficiency.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'item):': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'removal,': 0.16; 'subject:Advanced': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'basically': 0.18; 'instance,': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'code.': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'developing': 0.28; 'interface': 0.29; 'etc).': 0.29; "i'm": 0.30; 'code': 0.30; 'probably': 0.31; 'especially': 0.32; 'core': 0.32; 'skip:_ 10': 0.32; 'implement': 0.32; 'knows': 0.32; 'class': 0.33; 'doubt': 0.33; 'optimize': 0.33; 'structure': 0.34; 'add': 0.34; 'lists': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'something': 0.35; 'item': 0.35; 'reply.': 0.35; 'skip:p 30': 0.35; 'but': 0.36; 'too': 0.36; 'instead': 0.36; '(and': 0.36; 'structures': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'thanks': 0.37; 'list.': 0.37; "won't": 0.38; 'anything': 0.38; 'why': 0.39; 'data': 0.39; 'sure': 0.39; 'where': 0.40; 'your': 0.60; 'skip:u 10': 0.61; 'provide': 0.61; 'linked': 0.63; 'more': 0.63; 'necessarily': 0.63; 'sample': 0.63; 'great': 0.63; 'subject:Data': 0.66; 'teach': 0.70; 'jul': 0.72; 'obvious': 0.76; 'vital': 0.76; 'chrisa': 0.84; 'simple:': 0.84; 'study,': 0.84; 'to:none': 0.91; 'shares': 0.93; 'education,': 0.96; 'hands': 0.96 |
| 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 :content-transfer-encoding; bh=3JPFvgXG8EKDnylv76Mc9gLNEQBaMh0XHa9LZKNqt3g=; b=0eWLR+RwD54pI/1gkbuTSPj2IaUFQ4HnR23UMeMBFl1RIlfw6Vogwl63T+MNUV60Lg oeRu2k6Wj01I/hfnsv+dyKftVmouFrHqf5XzOnvQmWreQKtUsb7UFr7xffnIT9evG3Tt P8vU73XFzmZS0h6tQGu8Y5PCmR+3Luuuoz47OHxgBy8PG/dOFEo9S/OW9M6QxWkp7WrG Ns9ekja+vrNPs5BHRSu/6tePQKnEVFQYF9h8Qz4RR7MLa5FkPT+VnPW+qVcUEVpVROLg aYoQhDkpCt/c9Z70xTRG+cs/bEoPg+GDhOGnzhG8q9Rdp7iDbPhR2xWciLo3WOS/Xmsb UTtQ== |
| 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:content-transfer-encoding; bh=3JPFvgXG8EKDnylv76Mc9gLNEQBaMh0XHa9LZKNqt3g=; b=aoOZa/69hQVI0aN6R7sHY180nXZJvsqv8lTdKPD7l+YLJH6kHlp+F1i/zCKHIxXyO+ iHKvrroB8GLq9FpSrbXA9+w4WTQP0dVER+u/yoe4Jp0076Q3lR6HUyjxsjx1nDiTwWUm 4d8kaZvS7QxXAa3TBTR28eJNzJMtIvZYCwyQKVKTnhYlxZChia9hjBAaflUKLyLXu6kY xxqEqr91aZuRPcfmEi47ON5ydOOYdjaYYd07WSAsyseUwq9N3QxoMjZ1U3uLGGz6SPSH 682FWviuEWhWWvJof82rtWh4lV4FcvsmCsr3G2lxxvnlruhrrF/ck2NppZR48QHrd/Kn 8veA== |
| X-Gm-Message-State | ALyK8tJwK3CdEzw/CaNjjYCa62uM2/kMNzm9oLz8GTLK0WnD2lQwo9qrar01TOFiUtj9cs01MxSfmcg5ggZ5GQ== |
| X-Received | by 10.194.169.98 with SMTP id ad2mr5885746wjc.117.1468709113617; Sat, 16 Jul 2016 15:45:13 -0700 (PDT) |
| In-Reply-To | <7af57bf9-72d7-4d0f-8db4-3ea02d701a5f@googlegroups.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 | <CAPTjJmp2Bog+raRYVn+3GyjfLXY8=abEpVCCevjVB353DquNLQ@mail.gmail.com> |
| X-Mailman-Original-References | <21fcec53-cf5b-4529-9790-63a1c46f534b@googlegroups.com> <CAPTjJmpQk9SwLRct-WpZMywFFLhX3A459eNzB5eHGVFyhBiDoA@mail.gmail.com> <mailman.42.1468707584.2307.python-list@python.org> <7af57bf9-72d7-4d0f-8db4-3ea02d701a5f@googlegroups.com> |
| Xref | csiph.com comp.lang.python:111528 |
Show key headers only | View raw
On Sun, Jul 17, 2016 at 8:33 AM, Shrey Desai <shrey.desai@gmail.com> wrote:
> Hi Chris, thanks for the reply. There's a couple of reasons why I would need a Linked List (and other data structures):
> - Education: the Linked List is a core data structure that CS undergraduates (among others) use and study, so it is vital that they have hands on access to them. A list is basically a dynamic array; the only property it shares with a Linked List is that it's dynamic.
> - Development: the use of correct data structures is important when developing applications, especially for issues like scaling and efficiency. For instance, when working with polynomials, Linked Lists provide a great interface to access and edit them.
>
For education, I wouldn't worry too much about performance or edge
cases, and just use something really simple:
class LinkedList:
def __init__(self):
self.head = self.tail = None
def append(self, item):
if self.tail: self.tail = self.tail.append(item)
self.head = self.tail = _listitem(item)
class _listitem:
def __init__(self, item):
self.item = item
self.next = None
def append(self, item):
self.next = type(self)(item)
return self.next
Then add other methods as you teach them (iteration, item removal,
etc). Performance is probably terrible, but who cares? You won't
notice it in sample code.
For development, I'm pretty sure the native CPython list type is going
to out-perform anything you could implement as a linked list. Even
more so if you're using PyPy, where it knows how to optimize the list
(but won't necessarily be able to optimize your type). Instead of
messing around with data types, just implement your code using the
most simple and obvious style, and worry about
performance/scaling/efficiency only if and when you find out that
that's a bottleneck. I very much doubt that it will be.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PEP Request: Advanced Data Structures shrey.desai@gmail.com - 2016-07-16 15:14 -0700
Re: PEP Request: Advanced Data Structures Chris Angelico <rosuav@gmail.com> - 2016-07-17 08:19 +1000
Re: PEP Request: Advanced Data Structures Shrey Desai <shrey.desai@gmail.com> - 2016-07-16 15:33 -0700
Re: PEP Request: Advanced Data Structures Chris Angelico <rosuav@gmail.com> - 2016-07-17 08:45 +1000
Re: PEP Request: Advanced Data Structures Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-07-16 19:49 -0400
Re: PEP Request: Advanced Data Structures breamoreboy@gmail.com - 2016-07-16 16:21 -0700
Re: PEP Request: Advanced Data Structures Paul Rubin <no.email@nospam.invalid> - 2016-07-16 16:36 -0700
Re: PEP Request: Advanced Data Structures Terry Reedy <tjreedy@udel.edu> - 2016-07-16 20:10 -0400
Re: PEP Request: Advanced Data Structures MRAB <python@mrabarnett.plus.com> - 2016-07-17 01:38 +0100
Re: PEP Request: Advanced Data Structures Marko Rauhamaa <marko@pacujo.net> - 2016-07-17 10:26 +0300
Re: PEP Request: Advanced Data Structures Steven D'Aprano <steve@pearwood.info> - 2016-07-17 14:21 +1000
Re: PEP Request: Advanced Data Structures Tim Chase <python.list@tim.thechases.com> - 2016-07-16 19:45 -0500
Re: PEP Request: Advanced Data Structures Rustom Mody <rustompmody@gmail.com> - 2016-07-17 00:33 -0700
csiph-web