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.

classification
Title: Add clarification in documentation for heapq.heapify naming
Type: enhancement Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, hp685, rhettinger, steven.daprano
Priority: normal Keywords:

Created on 2020-02-14 20:29 by hp685, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18504 hp685, 2020-02-14 20:29
Messages (4)
msg361996 - (view) Author: Harsh Patel (hp685) * Date: 2020-02-14 20:29
heapify method is a misnomer in that it is actually the make-heap or build-heap procedure from textbooks
msg361999 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-02-14 21:59
The "-ify" or "-fy" suffix in English means "to make". For example, "amplify", "magnify", "terrify", etc.

https://en.wiktionary.org/wiki/-ify

So heapify literally means "make into a heap". Not only is the name correct, but it is a better name for an in-place operation than either of the terms you give:

* "build-heap" does not describe an in-place operation;
* "make-heap" is ambiguous in whether it is in-place or not.

But even if we agreed that the name needs to change to match text books (which text books?), since heapify is a public function, we cannot just change the name. We would have to keep the old name around for many, many years, possibly forever.
msg362003 - (view) Author: Harsh Patel (hp685) * Date: 2020-02-14 22:30
This ticket is not intended to rename heapify method in the stdlib (its too
late for that). This is to merely add a clarification in the docs to state
that heapify here has a different connotation than what's used in standard
algorithmic literature (CLRS, Sedgewick etc).  See here
https://xlinux.nist.gov/dads/HTML/heapify.html

References:
https://algs4.cs.princeton.edu/24pq/
http://math.utoledo.edu/~codenth/Fall_16/4380/heap-hw.pdf

On Fri, Feb 14, 2020 at 2:00 PM Steven D'Aprano <report@bugs.python.org>
wrote:

>
> Steven D'Aprano <steve+python@pearwood.info> added the comment:
>
> The "-ify" or "-fy" suffix in English means "to make". For example,
> "amplify", "magnify", "terrify", etc.
>
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__en.wiktionary.org_wiki_-2Dify&d=DwIFaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=owI_YZl60rgj74U9tzqxcA&m=jUulcI-27ChSIukpI4uzg0LktqA5zRt9HI8Lz0JxRYU&s=o95nXSmjNMCHMbmoWeL7LildI9qwEdnusnlAOenreQ4&e=
>
> So heapify literally means "make into a heap". Not only is the name
> correct, but it is a better name for an in-place operation than either of
> the terms you give:
>
> * "build-heap" does not describe an in-place operation;
> * "make-heap" is ambiguous in whether it is in-place or not.
>
> But even if we agreed that the name needs to change to match text books
> (which text books?), since heapify is a public function, we cannot just
> change the name. We would have to keep the old name around for many, many
> years, possibly forever.
>
> ----------
> nosy: +steven.daprano
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <
> https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.python.org_issue39634&d=DwIFaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=owI_YZl60rgj74U9tzqxcA&m=jUulcI-27ChSIukpI4uzg0LktqA5zRt9HI8Lz0JxRYU&s=kE5QfuakDzLUOPpeWAGCf7Z0zJeeeC1iDUSj-bMFzrE&e=
> >
> _______________________________________
>
msg362005 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-02-15 06:08
Thank you, but I'm going to decline this suggestion.

The docs are pretty clear about what heapify does:

* "To create a heap, use a list initialized to [], or you can transform a populated list into a heap via function heapify()."

* "Transform list x into a heap, in-place, in linear time."
History
Date User Action Args
2022-04-11 14:59:26adminsetgithub: 83815
2020-02-15 06:08:37rhettingersetstatus: open -> closed
resolution: not a bug
messages: + msg362005

stage: resolved
2020-02-15 01:19:13steven.dapranosetnosy: + rhettinger
2020-02-15 01:16:18steven.dapranosettitle: Add clarification in documentation for incorrect heapq heapify naming -> Add clarification in documentation for heapq.heapify naming
nosy: + docs@python

assignee: docs@python
components: + Documentation, - Library (Lib)
type: enhancement
2020-02-14 22:35:24hp685settitle: Incorrect heapq heapify naming -> Add clarification in documentation for incorrect heapq heapify naming
2020-02-14 22:30:28hp685setmessages: + msg362003
2020-02-14 21:59:24steven.dapranosetnosy: + steven.daprano
messages: + msg361999
2020-02-14 20:29:40hp685create