[Python-ideas] INSANE FLOAT PERFORMANCE!!!

Nick Coghlan ncoghlan at gmail.com
Wed Oct 12 11:09:29 EDT 2016


On 12 October 2016 at 21:35, Paul Moore <p.f.moore at gmail.com> wrote:
> What I'm *not* quite clear on is why Python 3's change to reject
> comparisons between unrelated types makes this optimisation possible.
> Surely you have to check either way? It's not that it's a particularly
> important question - if the optimisation works, it's not that big a
> deal what triggered the insight. It's just that I'm not sure if
> there's some other point that I've not properly understood.

It's probably more relevant that cmp() went away, since that
simplified the comparison logic to just PyObject_RichCompareBool,
without the custom comparison function path.

It *might* have still been possible to do something like this in the
Py2 code (since the main requirement is to do the pre-check for
consistent types if the first object is of a known type with an
optimised fast path), but I don't know anyone that actually *likes*
adding new special cases to already complex code and trying to figure
out how to test whether or not they've broken anything :)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list