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


Groups > comp.lang.python > #102753

Re: Heap Implementation

From Cem Karan <cfkaran2@gmail.com>
Newsgroups comp.lang.python
Subject Re: Heap Implementation
Date 2016-02-09 21:47 -0500
Message-ID <mailman.17.1455072436.7749.python-list@python.org> (permalink)
References (6 earlier) <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>

Show all headers | 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