Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Sven R. Kunze" Newsgroups: comp.lang.python Subject: Re: Bug in Python? Date: Sun, 28 Feb 2016 11:24:00 +0100 Lines: 36 Message-ID: References: <56D0CCE9.2000301@mail.de> <56d16fff$0$1605$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 3SzkREZG27ZEPkGRzMqtGgI+rK1HWMLjvoFQOdHc8ybg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'preferably': 0.05; '[],': 0.07; 'decision.': 0.09; 'falls': 0.09; 'okay': 0.09; 'subclass': 0.09; 'tracker,': 0.09; 'python': 0.10; '"to': 0.16; '*list*': 0.16; '2016': 0.16; 'heap': 0.16; 'heap,': 0.16; 'heapq': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'sad': 0.16; 'wrote:': 0.16; 'transform': 0.18; '>>>': 0.20; 'doc': 0.22; 'am,': 0.23; 'feb': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'checking': 0.27; 'function': 0.28; 'actual': 0.28; 'initialized': 0.29; 'issues.': 0.29; 'there.': 0.30; 'says': 0.32; "d'aprano": 0.33; 'steven': 0.33; 'handle': 0.34; 'previous': 0.34; 'received:10.0': 0.34; 'lists': 0.34; 'list': 0.34; 'best,': 0.35; 'instance': 0.35; 'lists.': 0.35; 'propose': 0.35; '(and': 0.36; "wasn't": 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'agree': 0.37; 'things': 0.38; 'version': 0.38; 'anything': 0.38; 'means': 0.39; 'why': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'chance': 0.60; 'your': 0.60; 'close': 0.61; 'real': 0.62; 'back': 0.62; 'charset:windows-1252': 0.62; 'else.': 0.66; 'increase': 0.73; '4:44': 0.91; 'hands': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mail201212; t=1456655042; bh=TYnwsfWRG1SSyQ1K0qW2qrLFfGwCrdZ2t1mlRPoANCg=; h=Subject:To:References:From:Date:In-Reply-To:From; b=pjMgeqYhjaMJkkAqMBCBzyMKRntctI2BaFywI1XshYm+aK4Uu+VkNnd+iU7KiuqbA L76OH1ooiqlxPb3AuASRqSvwxBA3oD/r2xWlb1NB/nhZQIMK0pk644iosZVnsOIRMC +1smjdthKxg+7eZdDdgoRj376Y8KF4t0KXnKctG8= In-Reply-To: X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 4125 X-purgate-ID: 154282::1456655042-00004575-80DBDFD7/0/0 X-Content-Filtered-By: Mailman/MimeDel 2.1.21rc2 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103621 On 27.02.2016 12:48, Terry Reedy wrote: > On 2/27/2016 4:44 AM, Steven D'Aprano wrote: >> On Sat, 27 Feb 2016 07:55 pm, Terry Reedy wrote: >> >>> In other words, when that doc says *list*, it means a *list*. >>> >>> "To create a heap, use a list initialized to [], or you can transform a >>> populated list into a heap via function heapify()." >> [...] >>> "A heap must be an instance of *list* (and not a subclass thereof). To >>> create a heap, start with [] or transform an existing list into a heap >>> via function heapify()." >> >> I think that's a sad decision. heapq ought to be able to handle any list >> subclass, not just actual lists. Preferably it ought to handle >> duck-typed >> lists too, anything with a list-like interface. It is okay if the >> optimized >> C version only works with actual lists, and falls back to a slower >> Python >> version for anything else. > I agree that it would increase comprehensibility. I took me a fair amount of time to see why things are not working as intended (and as you see I wasn't even close to the real explanation). However, heapq might work well the way it is as long as you have the chance to get your hands on one of the other heap implementations out there. > Propose that on the tracker, after checking previous issues. :) Best, Sven