[issue23699] Add a macro to ease writing rich comparisons

Stefan Krah report at bugs.python.org
Mon May 18 16:23:57 CEST 2015


Stefan Krah added the comment:

I mean it's clearer to have:

    result = long_compare(self, other);
    return Py_cmp_to_bool(result, op);

than:

    result = long_compare(self, other);
    Py_RETURN_RICHCOMPARE(result, 0, op);


This is because in other places, like the proposed use
case in

  https://mail.python.org/pipermail/python-ideas/2015-March/032564.html ,


the macro actually *performs* the "rich" comparison. In the above case
it just *converts* the result of long_compare().


Maybe the distinction does not matter in practice, but I'm not
too happy with it.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23699>
_______________________________________


More information about the Python-bugs-list mailing list