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


Groups > comp.lang.python > #102753

Re: Heap Implementation

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Cem Karan <cfkaran2@gmail.com>
Newsgroups comp.lang.python
Subject Re: Heap Implementation
Date Tue, 9 Feb 2016 21:47:12 -0500
Lines 26
Message-ID <mailman.17.1455072436.7749.python-list@python.org> (permalink)
References <56AD3D83.2050308@mail.de> <7C522D08-9D73-48D2-A71D-F1D1D34C02A5@gmail.com> <CACs7g=Cu=tGhU3TtBa0cYr46WP7kOHWyxz2TiHXCuiSLqb4P7A@mail.gmail.com> <185DAEA4-8728-4792-A3B7-7F6AC5A7F876@gmail.com> <CACs7g=APHr+DbmZaGz7P3RaRUGDYPqH+eniVTFenppPXXinOvQ@mail.gmail.com> <2308C08E-D2A1-4F16-800F-C2794D30F96B@gmail.com> <n9cc78$2rn$1@ger.gmane.org> <65105210-BAE5-4CD1-8C8C-73FC51982901@gmail.com> <n9ct0m$kcn$1@ger.gmane.org> <D283DC69-E9B1-4ED3-9A29-925E548A33CF@gmail.com> <CACs7g=DgctVw4Ko8uY2uJBcw2CS+zNEn_H987GexWKrbj-B8cA@mail.gmail.com>
Mime-Version 1.0 (Mac OS X Mail 6.6 \(1510\))
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de h9x3hztFdFGtjJMkqbSGwwA8EB/ylSvfXqvXpAZb2qXw==
Return-Path <cfkaran2@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'objects,': 0.07; 'wrapper': 0.07; 'cc:addr:python-list': 0.09; 'immutable': 0.09; 'mutable': 0.09; 'objects.': 0.09; 'pointers': 0.09; '2016': 0.16; 'element.': 0.16; 'heap': 0.16; 'received:192.168.1.4': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'element': 0.18; 'pointer': 0.18; 'cc:addr:python.org': 0.20; 'fix': 0.21; 'cc:2**1': 0.22; 'constant': 0.22; 'am,': 0.23; 'feb': 0.23; "python's": 0.23; 'thanks,': 0.24; 'header:In-Reply- To:1': 0.24; 'figure': 0.27; 'correct,': 0.29; 'faster,': 0.29; 'code': 0.30; 'implement': 0.32; 'language.': 0.32; 'message- id:@gmail.com': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'too': 0.36; 'should': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'received:209': 0.38; 'received:209.85.220': 0.38; 'received:192': 0.39; 'still': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.61; 'removal': 0.79; '6:11': 0.84; 'cc:addr:yahoo.co.uk': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=+Q0oGrLNwZJVRPO8de9Xe3zel57d4fUqY3357P6dUS8=; b=u1wOH1VKjn10Jm9rnW5ZDEBhganwj6gp3fxjhLLfBoodz6d+f4XYruFfwnR3rtAPUn Un4wE3BXuzuOyDKKT+dsNy2lxy7Q7R3evsFskjsA/Kxjt7AXNrlQBOm008z/WpkMhntZ QCTTasHrjo7ERXayK2ExfCH+cpaZRx8VfQuMlLH4P4/8bBf+MqOnM1o5ZoxxHzZPuPjT ayRHzc0VdyrxIrV+LE+w4VMezH0XTyNFYsx1JT+wvh5qJOiAV6waQVllGrm3/px6REwd D77g9qpPVBOxQFlV/y9GkmKv+dEWVRg4J3tGflzzxmIE4x6vfx7Qxl6uA6SHLEOrmEkn 8RUA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=+Q0oGrLNwZJVRPO8de9Xe3zel57d4fUqY3357P6dUS8=; b=SlNgDNq5ZAEWjwEl1m1ChlwCvk/Xl2GR3vYquLkFir5VCh2O1Lg7vnVtEy93p5t6pX mJMovzZnMUZvIVfAdjBhM/xy6p5NRso1uKhMDztlf8RNcKZn7UDiGxQuNVV1WgbYxpFL yvxeKZ+loODWAInNo36+RqKE5r6601h7VKshHE+dekJBJ8Ns0YuDZGdSbudMs4kj6LMi ofiXbvKxcez6kYW5TtyogkTLZ9ojTPklZeGeOza63qyqmFfh1QGialeZcBBQPliTzefQ 0KqhodaoRN9hdkhXY6Lr80opIkRQwARJbDtmJ9UxnYBZshDdX/e6mmbgYt1/GLw42+GE z0Og==
X-Gm-Message-State AG10YOS7a113p4gvrenhoAogEiAtX0OlGzd1xWg86lzfw0g8kJTxwKfiNHVZHxuIqUUUAw==
X-Received by 10.55.56.134 with SMTP id f128mr45090531qka.92.1455072434036; Tue, 09 Feb 2016 18:47:14 -0800 (PST)
In-Reply-To <CACs7g=DgctVw4Ko8uY2uJBcw2CS+zNEn_H987GexWKrbj-B8cA@mail.gmail.com>
X-Mailer Apple Mail (2.1510)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc2
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>
Xref csiph.com comp.lang.python:102753

Show key headers only | View raw


On Feb 9, 2016, at 8:27 PM, srinivas devaki <mr.eightnoteight@gmail.com> wrote:

> 
> 
> On Feb 10, 2016 6:11 AM, "Cem Karan" <cfkaran2@gmail.com> wrote:
> >
> > Eh, its not too bad once you figure out how to do it.  It's easier in C though; you can use pointer tricks that let you find the element in constant time, and then removal will involve figuring out how to fix up your heap after you've removed the element.
> >
> 
> If you can do it with C pointers then you can do it with python's references/mutable objects. :)
> in case of immutable objects, use a light mutable wrapper or better use list for performance.

I should have been clearer; it's easier to UNDERSTAND in C, but you can implement it in either language.  C will still be faster, but only because its compiled.  It will also take a lot longer to code and ensure that it's correct, but that is the tradeoff.

Thanks,
Cem Karan

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


Thread

Re: Heap Implementation Cem Karan <cfkaran2@gmail.com> - 2016-02-09 21:47 -0500

csiph-web