This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author petr.viktorin
Recipients barry, ethan.furman, lemburg, petr.viktorin, rhettinger, serhiy.storchaka, skrah
Date 2015-05-18.14:55:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1431960956.09.0.552237141293.issue23699@psf.upfronthosting.co.za>
In-reply-to
Content
Conceptually there's a distinction between the two cases, but you can implement one in terms of the other, so I don't think it's worth adding two functions/macros here. So let's pick the better API.

"Py_cmp_to_bool" is better if you already have a cmp-style result. Python code is full of cmp-style results, but I think a big reason is that py2 required them, and (rightly) nobody wants to rewrite the algorithms. I believe the py3 way of passing in the operator is better API.

I've seen (a - b) far too many times, which gives the right result in most but *not all* cases. (Think small floats where the difference is coerced to int for the Py_cmp_to_bool function. Or int overflow.)
The correct ways to get a cmp-style result are "(a > b) - (a < b)" or "(a < b) ? -1 : (a > b)". Do we want to add a function that requires you to write, read, and understand that?
History
Date User Action Args
2015-05-18 14:55:56petr.viktorinsetrecipients: + petr.viktorin, lemburg, barry, rhettinger, skrah, ethan.furman, serhiy.storchaka
2015-05-18 14:55:56petr.viktorinsetmessageid: <1431960956.09.0.552237141293.issue23699@psf.upfronthosting.co.za>
2015-05-18 14:55:56petr.viktorinlinkissue23699 messages
2015-05-18 14:55:55petr.viktorincreate