Possible typo in docs
page in question: https://docs.python.org/2/library/heapq.html section: 8.4.2. Priority Queue Implementation Notes Currently: def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry = entry_finder.pop(task) entry[-1] = REMOVED As it stands, 'task' is removed from dictionary 'entry_finder' and never replaced which is not the intention in my opinion. Possible fixes: 1.def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry = entry_finder.pop(task) entry[-1] = REMOVED entry_finder[task] = entry 2.def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry_finder[task][-1] = REMOVED Sincerely,AM
Hello Andrew, You are right. The task should not be pop'ed out of the entry_finder dictionary. I prefer the 2nd approach over the 1st one where the task is re-added back to the dictionary. def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry_finder[task][-1] = REMOVED I will correct it in the docs. -- Senthil On Wed, Apr 6, 2016 at 3:42 AM, Andrew McFarland < andrew.mcfarland@outlook.com> wrote:
page in question: https://docs.python.org/2/library/heapq.html
section: * 8.4.2. Priority Queue Implementation Notes*
Currently:
def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry = entry_finder.pop(task) entry[-1] = REMOVED
As it stands, 'task' is removed from dictionary 'entry_finder' and never replaced which is not the intention in my opinion.
Possible fixes:
1. def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry = entry_finder.pop(task) entry[-1] = REMOVED entry_finder[task] = entry
2. def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry_finder[task][-1] = REMOVED
Sincerely, AM
_______________________________________________ docs mailing list docs@python.org https://mail.python.org/mailman/listinfo/docs
Replying again. The docs as it stands is correct. The entry_finder is merely used as pointer to the lastest task and the task itself is not removed from the heapq. Removing the task using entry_pop.() would not be affecting this as it is anyways overridden in line 6 in the add_task. So, no change is needed here. Thank you, Senthil On Thu, Apr 7, 2016 at 8:40 PM, Senthil Kumaran <senthil@uthcode.com> wrote:
Hello Andrew,
You are right. The task should not be pop'ed out of the entry_finder dictionary. I prefer the 2nd approach over the 1st one where the task is re-added back to the dictionary.
def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry_finder[task][-1] = REMOVED
I will correct it in the docs.
-- Senthil
On Wed, Apr 6, 2016 at 3:42 AM, Andrew McFarland < andrew.mcfarland@outlook.com> wrote:
page in question: https://docs.python.org/2/library/heapq.html
section: * 8.4.2. Priority Queue Implementation Notes*
Currently:
def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry = entry_finder.pop(task) entry[-1] = REMOVED
As it stands, 'task' is removed from dictionary 'entry_finder' and never replaced which is not the intention in my opinion.
Possible fixes:
1. def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry = entry_finder.pop(task) entry[-1] = REMOVED entry_finder[task] = entry
2. def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry_finder[task][-1] = REMOVED
Sincerely, AM
_______________________________________________ docs mailing list docs@python.org https://mail.python.org/mailman/listinfo/docs
participants (2)
-
Andrew McFarland -
Senthil Kumaran