A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-June/025938.html below:

[Python-Dev] Priority queue (binary heap) python code

[Python-Dev] Priority queue (binary heap) python codeKevin O'Connor kevin@koconnor.net
Tue, 25 Jun 2002 18:26:06 -0400
On Mon, Jun 24, 2002 at 11:09:32PM -0500, Skip Montanaro wrote:
> I don't know how efficient it would be, but I usually think that most
> applications have a small, fixed set of possible priorities, like ("low",
> "medium", "high") or ("info", "warning", "error", "fatal").  In this sort of
> situation my initial inclination would be to implement a dict of Queue
> instances which corresponds to the fixed set of priorities, something like:

Hi Skip,

The application I had in mind stored between 100,000-1,000,000 objects with
priorities between 0-150.  I found that moving from bisect to a heap
improved performance of the entire program by about 25%.

>It will also work if for some reason you want
> to queue up objects for which __cmp__ doesn't make sense.

I just assumed the user would use the (priority, data) tuple trick at the
start (it does make the algorithm simpler).  In a way, the code is very
similar to the way the bisect module is implemented.

-Kevin

-- 
 ------------------------------------------------------------------------
 | Kevin O'Connor                     "BTW, IMHO we need a FAQ for      |
 | kevin@koconnor.net                  'IMHO', 'FAQ', 'BTW', etc. !"    |
 ------------------------------------------------------------------------




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4