heapq.heappush and pop to use key

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Thu Mar 8 11:02:56 EST 2007


In <1173364305.281085.271320 at t69g2000cwt.googlegroups.com>,
jm.suresh at no.spam.gmail.com wrote:

> I wanted to have a heap of custom objects, and in different heaps I
> wanted to have the weights for my elements differently. So, I modified
> the heapq module to accept key arguments also.

I would have just used tuples of the form (weight, obj) with the original
`heapq` module.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list