import heapq import random sample = [random.randint(0, 1000) for _ in range(100)] print(min(sample)) # O(N) heapq.heapify(sample) # O(N) print(sample[0]) # O(1)