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


Groups > comp.lang.python > #101446

Re: How to remove item from heap efficiently?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From "Sven R. Kunze" <srkunze@mail.de>
Newsgroups comp.lang.python
Subject Re: How to remove item from heap efficiently?
Date Sun, 10 Jan 2016 19:50:18 +0100
Lines 14
Message-ID <mailman.9.1452451826.3151.python-list@python.org> (permalink)
References <568EEC40.7070807@mail.de> <CACs7g=Bjccja67M3t4yL+07vO8iAcOB-dF5p2PgqqBwjFmbh=w@mail.gmail.com> <mailman.84.1452351069.2305.python-list@python.org> <87lh7ywqm7.fsf@nightsong.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de aFzUXP7noDoH/JSUn3PhiAbHR/2BIWa5HdBD2VtvLaHg==
Return-Path <srkunze@mail.de>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:How': 0.09; 'dict': 0.09; 'indexes': 0.09; 'item,': 0.09; 'thrown': 0.09; 'received:io': 0.16; 'received:psf.io': 0.16; 'sorting': 0.16; 'subject:item': 0.16; 'subject:remove': 0.16; 'wrote:': 0.16; 'basically': 0.18; 'tree': 0.18; 'suggested': 0.20; 'keys': 0.22; 'header:In-Reply-To:1': 0.24; 'paul': 0.24; 'header:User-Agent:1': 0.26; 'separate': 0.27; 'query': 0.30; 'task': 0.30; 'table': 0.32; 'items.': 0.33; 'received:10.0': 0.34; 'best,': 0.35; 'tasks': 0.35; 'too': 0.36; 'structures': 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'two': 0.37; 'subject:from': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'received:de': 0.40; 'real': 0.62; 'charset:windows-1252': 0.62; 'different': 0.63; 'balanced': 0.84; 'dict.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mail201212; t=1452451819; bh=eqWq43CqZ2BunfQED1ITQXTSdgN4s7ukGWu27NGXAds=; h=Subject:To:References:From:Date:In-Reply-To:From; b=cEFD19O6ANFDDRAkzoqyAtOfiPKWmwfkn8UkI1jE77/41umIQgfN3NxSIvZDAeM4N UhHCgUaVwcP2Ex5i6E+gaoMTQwGLvZ/tBBc24ZBPGz5ipWf0LUzYNg8He8FauORci4 bummir7rbJBcRh2vu6UUQ15jW4UQ5pBZ7EZRAAS0=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
In-Reply-To <87lh7ywqm7.fsf@nightsong.com>
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 591
X-purgate-ID 154282::1452451819-000009F3-CE11669C/0/0
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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:101446

Show key headers only | View raw


On 09.01.2016 19:32, Paul Rubin wrote:
> "Sven R. Kunze" <srkunze@mail.de> writes:
>> Basically a task scheduler where tasks can be thrown away once they
>> are too long in the queue.
> I don't think there's a real nice way to do this with heapq.  The
> computer-sciencey way would involve separate balanced tree structures
> for the two sorting keys (think of a database table with indexes on two
> different columns).

Others suggested using an additional dict where to store the indexes of 
the items. Then, when removing an item, I just need to query the dict.

Best,
Sven

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


Thread

Re: How to remove item from heap efficiently? "Sven R. Kunze" <srkunze@mail.de> - 2016-01-08 17:45 +0100
  Re: How to remove item from heap efficiently? Paul Rubin <no.email@nospam.invalid> - 2016-01-09 10:32 -0800
    Re: How to remove item from heap efficiently? "Sven R. Kunze" <srkunze@mail.de> - 2016-01-10 19:50 +0100
    Re: How to remove item from heap efficiently? srinivas devaki <mr.eightnoteight@gmail.com> - 2016-01-12 08:38 +0530
      Re: How to remove item from heap efficiently? Paul Rubin <no.email@nospam.invalid> - 2016-01-11 19:16 -0800

csiph-web