[PEAK] trellis.SortedSet bug and patch
Phillip J. Eby
pje at telecommunity.com
Thu Dec 4 00:38:16 EST 2008
At 05:03 PM 12/3/2008 -0800, Grant Baillie wrote:
>I was running a doctest involving collections.SortedSet and ran into a
>bug where the sorting got out of whack. It turns out there's a funny
>comparison going on in collections.py, line 221: we're comparing a
>single value to a 2-element tuple, which is probably not what's
>Then I found the obvious attempt to fix it could also be broken with
>similar edge cases. So, below find the patch, and the 4 tests I wrote.
>Actually, in retrospect, I'm wondering if we should just bypass the
>"shortcut" case completely. Is it that much of a performance win?
Function calls are expensive in Python, and the operation is in a
loop. Then again, in a typical case there won't be that many
iterations in the loop. So, probably not, especially now that the
"shortcut" is more complicated.
More information about the PEAK