Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'third-party': 0.04; 'tree': 0.05; 'assignment': 0.07; 'explicit': 0.07; 'pypi': 0.07; 'removes': 0.07; 'curve': 0.09; 'exist,': 0.09; 'happens.': 0.09; 'inclusion': 0.09; 'input,': 0.09; 'lawrence': 0.09; 'merging': 0.09; 'pep': 0.09; 'preferable': 0.09; 'promising': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rejected': 0.09; 'structure,': 0.09; 'python': 0.11; 'language.': 0.14; 'collections': 0.16; 'containers': 0.16; 'deletion': 0.16; 'doubles': 0.16; 'fifo': 0.16; 'foolishly': 0.16; 'jumps': 0.16; 'pruning': 0.16; 'rarely': 0.16; 'rather,': 0.16; 'reason.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'slicing,': 0.16; 'sorts': 0.16; 'subject:library': 0.16; 'trees:': 0.16; 'url:peps': 0.16; 'essential': 0.16; 'appropriate': 0.16; 'url:)': 0.16; 'language': 0.16; 'wrote:': 0.18; 'library': 0.18; 'looked': 0.18; 'all,': 0.19; '(but': 0.19; 'unlike': 0.19; 'solution.': 0.20; 'fit': 0.20; 'written': 0.21; 'header:User-Agent:1': 0.23; 'finally,': 0.24; 'module,': 0.24; 'replace': 0.24; 'url:dev': 0.24; 'java': 0.24; '---': 0.24; "i've": 0.25; 'second': 0.26; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'specifically': 0.29; "we'd": 0.29; 'raise': 0.29; 'scanned': 0.29; "doesn't": 0.30; '(like': 0.30; 'raymond': 0.30; 'especially': 0.30; '(which': 0.31; 'went': 0.31; 'code': 0.31; 'equivalent.': 0.31; 'factor': 0.31; 'fast.': 0.31; 'idea,': 0.31; 'libraries': 0.31; 'loads': 0.31; 'stories.': 0.31; 'lists': 0.32; 'selection': 0.32; 'regular': 0.32; 'url:python': 0.33; 'cases': 0.33; 'copying': 0.34; "i'd": 0.34; 'could': 0.34; 'problem': 0.35; 'operations': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'really': 0.36; 'instances': 0.36; 'largely': 0.36; 'library.': 0.36; 'module.': 0.36; 'much.': 0.36; 'reflect': 0.36; 'useful': 0.36; 'url:org': 0.36; 'so,': 0.37; 'two': 0.37; 'list': 0.37; 'list.': 0.37; 'performance': 0.37; 'sometimes': 0.38; 'branch': 0.38; 'needed': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'viruses': 0.61; 'success': 0.61; 'protection': 0.63; 'our': 0.64; 'become': 0.64; 'more': 0.64; 'different': 0.65; 'chance': 0.65; 'linked': 0.65; 'effectively': 0.66; 'worth': 0.66; 'believe': 0.68; 'benefit': 0.68; 'advantages': 0.68; 'antivirus': 0.68; 'nobody': 0.68; 'real-world': 0.68; 'superior': 0.69; 'home.': 0.72; 'further,': 0.74; 'obvious': 0.74; 'balanced': 0.84; 'misses': 0.84; 'much,': 0.84; 'pocket': 0.84; 'points,': 0.84; 'python-dev': 0.84; 'scarily': 0.84; 'demand': 0.91; 'good,': 0.91; 'obvious,': 0.91; 'url:ru': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: blist in standard library (was Re: Balanced trees) Date: Sat, 15 Mar 2014 12:31:26 +0000 References: <87eh2d3x8h.fsf_-_@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-78-147-28-104.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: X-Antivirus: avast! (VPS 140315-0, 15/03/2014), Outbound message X-Antivirus-Status: Clean 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: 98 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394886716 news.xs4all.nl 2870 [2001:888:2000:d::a6]:53482 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68366 On 15/03/2014 01:13, Joshua Landau wrote: > On 8 March 2014 20:37, Mark Lawrence wrote: >> I've found this link useful http://kmike.ru/python-data-structures/ >> >> I also don't want all sorts of data structures added to the Python library. >> I believe that there are advantages to leaving specialist data structures on >> pypi or other sites, plus it means Python in a Nutshell can still fit in >> your pocket and not a 40 ton articulated lorry, unlike the Java equivalent. > > The thing we really need is for the blist containers to become stdlib > (but not to replace the current list implementation). The rejected PEP > (http://legacy.python.org/dev/peps/pep-3128/) misses a few important > points, largely in how the "log(n)" has a really large base: > random.choice went from 1.2µs to 1.6µs from n=1 to n=10⁸, vs 1.2µs for > a standard list. > > Further, it's worth considering a few advantages: > > * copy is O(1), allowing code to avoid mutation by just copying its > input, which is good practice. > > * FIFO is effectively O(1), as the time just about doubles from n=1 to > n=10⁸ so will never actually branch that much. There is still a speed > benefit of collections.deque, but it's much, much less significant. > This is very useful when considering usage as a multi-purpose data > structure, and removes demand for explicit linked lists (which have > foolishly been reimplemented loads of times). > > * It reduces demand for trees: > * There are efficient implementations of sortedlist, sortedset and > sorteddict. > * Slicing, slice assignment and slice deletion are really fast. > * Addition of lists is sublinear. Instead of > "list(itertools.chain(...))", one can add in a loop and end up > *faster*. > > I think blist isn't very popular not because it isn't really good, but > because it isn't a specialised structure. It is, however, almost there > for almost every circumstance. This can help keep the standard library > clean, especially of tree data structures. > > Here's what we kill: > > * Linked lists and doubly-linked lists, which are scarily popular for > whatever reason. Sometimes people claim that collections.deque isn't > powerful enough for whatever they want, and blist will almost > definitely sate those cases. > > * Balanced trees, with blist.sortedlist. This is actually needed right now. > > * Poor performance in the cases where a lot of list merging and pruning happens. > > * Most uses of bisect. > > * Some instances where two data structures are used in parallel in > order to keep performance fast on disparate operations (like `x in y` > and `y[i]`). > > Now, I understand there are downsides to blist. Particularly, I've > looked through the "benchmarks" and they seem untruthful. Further, > we'd need a maintainer. Finally, nobody jumps at blists because > they're rarely the obvious solution. Rather, they attempt to be a > different general solution. Hopefully, though, a stdlib inclusion > could make them a lot more obvious, and support in some current > libraries could make them feel more at home. > > I don't know whether this is a good idea, but I do feel that it is > more promising and general than having a graph in the standard > library. > I'd raise this on python-dev or python ideas as a result of reading PEP 3128. Specifically the second paragraph states Raymond Hettinger's sage advice:- "Depending on its success as a third-party module, it still has a chance for inclusion in the collections module. The essential criteria for that is whether it is a superior choice for some real-world use cases. I've scanned my own code and found no instances where BList would have been preferable to a regular list. However, that scan has a selection bias because it doesn't reflect what I would have written had BList been available. So, after a few months, I intend to poll comp.lang.python for BList success stories. If they exist, then I have no problem with inclusion in the collections module. After all, its learning curve is near zero -- the only cost is the clutter factor stemming from indecision about the most appropriate data structure for a given task." -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com