>>> from heapq import heappush
>>> heap = []
>>> heappush(heap,(0,{"k":0}))
>>> heappush(heap,(0,{"k":1}))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: '<' not supported between instances of 'dict' and 'dict'
This is mentioned in the official heapq document for python2 and python3 and the document suggests a DIY implementation of heapq
to mitigate this problem.
Why is this happening? What is the underlying reason that such conflict is not resolved, giving that heapq
is a really old library?
Are there performance / other concerns for this?
Why can't we just provide parameters like keep_old, keep_any
as a feature to this library?