[IronPython] Rich comparison usage by IronPython's heapq implementation
robert at smallshire.org.uk
Mon Mar 14 06:04:25 PDT 2011
I recently ran into some issues with IronPython's heapq implementation
whereby code that functions correctly on CPython failed with IronPython 2.6.
The issue is that the CPython implementation of heapq only calls __le__()
and __eq__() on the heap elements whereas the IronPython implementation
calls __le__(), __eq__() *and* __gt__(). Although it seems that IronPython
is well within specification to do so, there are some statements in the
Python documentation that only __le__() will be used for sorting. Of
course, it's arguable whether 'sorting' applies to heapq and indeed other
similar algorithms or containers which rely on a defined ordering.
In any case, this is an avoidable difference between CPython and IronPython
which tripped me up. I'm not sure whether the correct fix - if one is
needed at all - is to IronPython's heapq implementation, to CPythons
documentation, or to both.
I wrote a little more about the issue here:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Users