You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wouldn't it be useful to add a "key" argument to some heapq functions ?
So you could construct a heap from dict items list based on the second
item of each tuple, for example.
Rejecting the key-function patch in favor of the current typical
approach of heapifying tuples that link a priority level with
individual records. I've been a heavy user of the module and one of
its principal maintainers. To date, I've seen very little need for key-
function argument.
Use cases aside, there is another design issue in that the key-function
approach doesn't work well with the heap functions on regular lists.
Successive calls to heap functions will of necessity call the key-
function multiple times for any given element. This contrasts with sort
() where the whole purpose of the key function was to encapsulate the
decorate-sort-undecorate pattern which was desirable because the key-
function called exactly once per element.
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: