New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
heapq should provide iterators: itersmallest, iterlargest #41663
Comments
The current C-based heapq implementation provides Why: The functions nsmallest() and nlargest() are efficient Possible counter-arguments: The straight-forward iterator implementation will |
Logged In: YES The idea for introducing heapiter() function was http://mail.python.org/pipermail/python-dev/2004-June/045348.html The use cases were rare and the pure python solution was If you need C coded max-heaps, that could be a separate |
Logged In: YES "easy and fast" was the python solution for min-heaps, you I don't think max-heaps are less common than min-heaps in The major issue with the current heapq implementation is the h = heap(myIterator, reverse=true)
for item in h: print item would be so handy... For the use-cases: As I said before, nsmallest/nlargest are And again: most of the code is already there. Another possible solution: what about a module function Just an idea... |
Logged In: YES I am -1 on this feature request. The design of the module Building out the API for maxheap functions makes the module The case for an iterator wrapper is not strong. It was not Most user needs are met by sort(), nlargest(), nsmallest(), IMO, introducing iterators and maxheaps do not add enough The story would be somewhat different if the heaps had The OP's corner use case presented on comp.lang.python was |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: