This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients rajathagasthya, rhettinger, stutzbach, tim.peters
Date 2017-08-13.18:46:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1502650015.7.0.217327462888.issue31186@psf.upfronthosting.co.za>
In-reply-to
Content
@Rajath, I suspect Raymond may have been bamboozled because your suggested `heapfix()` and `heapremove()` didn't appear to take any arguments.  If the index is a required argument, then these are O(log N) operations.

I thought about adding them years ago, but didn't find a _plausible_ use case:  the index at which a specific heap item appears is pretty much senseless, and typically varies over a heap's lifetime.  So how does the user know _which_ index to pass?  A linear search over the underlying list to find the index of a specific heap item is probably unacceptable.

The only hacks around that I could think of required a more complex kind of heap; e.g., restricting heap items to objects usable as dict keys, using a hidden dict to map heap items to their current index, and fiddling all the heap operations to keep that dict up to date.

So, in the absence of an obvious way to proceed, I gave up :-)
History
Date User Action Args
2017-08-13 18:46:55tim.peterssetrecipients: + tim.peters, rhettinger, stutzbach, rajathagasthya
2017-08-13 18:46:55tim.peterssetmessageid: <1502650015.7.0.217327462888.issue31186@psf.upfronthosting.co.za>
2017-08-13 18:46:55tim.peterslinkissue31186 messages
2017-08-13 18:46:55tim.peterscreate