[Python-Dev] Impoverished compare ...
Erik
python at lucidity.plus.com
Thu Mar 9 18:43:20 EST 2017
Hi.
I'm looking at stuff proposed over on Python-Ideas, and I'd appreciate
some pointers as to the basics of how C-level objects are generally
compared in Python 3.
The issue is related to the performance of PyObject_RichCompare. I got
to the point where I was trying to work out what was the _alternative_
to RichCompare. If a comparison is not "rich", then what is it? There's
a tp_richcompare slot in the type structure, but I haven't noticed
anything else obvious for simple comparison (In 2.x days - which I have
more experience with - __cmp__ was a thing which now seems to be gone. I
understand the Python-level changes with sort(..., key=foo) but I've not
looked at the underlying C implementation until now).
Anyway, I followed things as far as Objects/typeobject.c and then I got
bitten by a macro dialect that I don't immediately grok, so anything
that spells it out a bit more plainly would be nice (I can follow the
code if I need to - but a shortcut from those who know this off the top
of their head would be helpful).
Thanks, E.
More information about the Python-Dev
mailing list