Yes, you can make this assumption, because it is stated in the documentation:

Heaps are arrays for which heap[k] <= heap[2*k+1] and heap[k] <= heap[2*k+2] for all k, counting elements from zero. For the sake of comparison, non-existing elements are considered to be infinite. The interesting property of a heap is that heap[0] is always its smallest element.

(And that's probably the reason there is no peek function: there is no need for it.)

Answer from Stephan202 on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › heap-queue-or-heapq-in-python
Heap queue or heapq in Python - GeeksforGeeks
Python provides a built-in module called heapq that allows to create and work with heap queues
Published   2 weeks ago
🌐
Python
docs.python.org › 3 › library › heapq.html
heapq — Heap queue algorithm
The heapq API differs from textbook heap algorithms in two aspects: (a) We use zero-based indexing. This makes the relationship between the index for a node and the indexes for its children slightly less obvious, but is more suitable since Python uses zero-based indexing.
🌐
Stack Abuse
stackabuse.com › guide-to-heaps-in-python
Guide to Heaps in Python
April 18, 2024 - Explore the intricacies of heaps, a tree-based data structure adept at maintaining order and hierarchy. Dive into Python's' heapq module, offering a rich set of functionalities for managing dynamic data sets where priority elements are frequently accessed. Learn how heaps stand out in the world ...
🌐
Delft Stack
delftstack.com › home › howto › python › python heapq peek
How to Peek Heapq in Python | Delft Stack
February 2, 2024 - The following code snippet shows how we can use the heapq.heappop() function to peek at the smallest element inside a heap in Python.
🌐
APXML
apxml.com › courses › data-structures-algorithms-ml › chapter-5-heaps-priority-queues-ml › python-heapq
Python heapq Module for Heap Operations
Since heapq uses a list where the first element heap[0] is always the smallest, you can peek at the minimum value without removing it simply by accessing the element at index 0.
Find elsewhere
🌐
Johnlekberg
johnlekberg.com › blog › 2020-11-01-stdlib-heapq.html
Python's heapq module
This week's Python blog post is about Python's heapq module.
🌐
Code Like A Girl
code.likeagirl.io › python-min-heap-priority-queue-interview-prep-66f127db1176
Python Min Heap — Priority Queue-Interview Prep | by Python Code Nemesis | Code Like A Girl
November 14, 2023 - The heapq module in Python makes life a lot easier. Now you have successfully implemented the Dijkstra algorithm using the minheap. Now, you need to explain the time complexity to the interviewer. The time complexities for various heap operations using the heapq module in Python are as follows:
🌐
GitHub
gist.github.com › marccarre › 577a55850998da02af3d4b7b98152cf4
Min and max heaps in Python · GitHub
Min and max heaps in Python. GitHub Gist: instantly share code, notes, and snippets.
🌐
Hello Interview
hellointerview.com › learn › code › heap › overview
Heap Overview | Hello Interview
peek(): Get the root element without removing it. heapify([elements]): Convert an array into a heap in-place. We'll learn about each of these operations on a min-heap by visualizing how both the array and binary tree representation of a heap ...
🌐
Medium
medium.com › @hs_pedro › implementing-a-heap-in-python-1036e759e0eb
Implementing a Heap in Python. Heap is an elegant data structure that… | by Pedro Soares | Medium
December 20, 2021 - For instance, one can heapify an ... and implementation of the following methods: peek (or find-minimum): returns the smallest key stored in constant time...
🌐
Medium
medium.com › the-pythonworld › why-hardly-anyone-uses-pythons-heapq-but-should-9e11052e409b
Why Hardly Anyone Uses Python’s heapq (But Should) | by Aashish Kumar | The Pythonworld | Medium
October 5, 2025 - The Hidden Gem in Python’s Standard Library That Most Developers Ignore Why Hardly Anyone Uses Python’s heapq (But Should) It’s fast, it’s built-in, and it solves real-world problems — yet …
🌐
Python
docs.python.org › 3.0 › library › heapq.html
heapq — Heap queue algorithm — Python v3.0.1 documentation
>>> from heapq import heappush, heappop >>> heap = [] >>> data = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0] >>> for item in data: ... heappush(heap, item) ... >>> ordered = [] >>> while heap: ... ordered.append(heappop(heap)) ...
🌐
Stackify
stackify.com › a-guide-to-python-priority-queue
A Guide to Python Priority Queue - Stackify
February 18, 2025 - While built-in options like PriorityQueue and heapq work well for many cases, sometimes you need more flexibility. For example, you might want to extend functionality, customize the priority logic, or add extra features like a peek method. A custom heapq implementation allows you to tailor ...
🌐
Real Python
realpython.com › python-heapq-module
The Python heapq Module: Using Heaps and Priority Queues – Real Python
July 18, 2022 - In this step-by-step tutorial, you'll explore the heap and priority queue data structures. You'll learn what kinds of problems heaps and priority queues are useful for and how you can use the Python heapq module to solve them.
🌐
Hello Algo
hello-algo.com › en › chapter_heap › heap
8.1 Heap - Hello Algo
/* Initialize a heap */ // Initialize a min heap Queue<Integer> minHeap = new PriorityQueue<>(); // Initialize a max heap (use lambda expression to modify Comparator) Queue<Integer> maxHeap = new PriorityQueue<>((a, b) -> b - a); /* Push elements into the heap */ maxHeap.offer(1); maxHeap.offer(3); maxHeap.offer(2); maxHeap.offer(5); maxHeap.offer(4); /* Get the heap top element */ int peek = maxHeap.peek(); // 5 /* Remove the heap top element */ // The removed elements will form a descending sequence peek = maxHeap.poll(); // 5 peek = maxHeap.poll(); // 4 peek = maxHeap.poll(); // 3 peek = maxHeap.poll(); // 2 peek = maxHeap.poll(); // 1 /* Get the heap size */ int size = maxHeap.size(); /* Check if the heap is empty */ boolean isEmpty = maxHeap.isEmpty(); /* Build a heap from an input list */ minHeap = new PriorityQueue<>(Arrays.asList(1, 3, 2, 5, 4));
🌐
GeeksforGeeks
geeksforgeeks.org › python › heap-and-priority-queue-using-heapq-module-in-python
Heap and Priority Queue using heapq module in Python - GeeksforGeeks
July 23, 2025 - The priority queue is implemented in Python as a list of tuples where the tuple contains the priority as the first element and the value as the next element. ... Consider a simple priority queue implementation for scheduling the presentations of students based on their roll number. Here roll number decides the priority of the student to present. Since it is a min-heap, roll number 1 is considered to be of the highest priority. ... # import modules import heapq as hq # list of students list_stu = [(5,'Rina'),(1,'Anish'),(3,'Moana'),(2,'cathy'),(4,'Lucy')] # Arrange based on the roll number hq.heapify(list_stu) print("The order of presentation is :") for i in list_stu: print(i[0],':',i[1])