[Python-ideas] A macro for easier rich comparisons
Andrew Barnert
abarnert at yahoo.com
Fri Mar 20 23:19:09 CET 2015
On Mar 20, 2015, at 7:24 AM, Petr Viktorin <encukou at gmail.com> wrote:
>
> A sequence of comparisons is less efficient than a switch statement.
> Same with PyBool_FromLong vs. Py_RETURN_*
> Also, it might be too complex for a macro.
> These points could be solved by making it a function instead.
Or by just making the macro a statement instead of a function; then the code can be exactly the same code you're abstracting out, and instead of using it like this:
return PY_RICHCOMPARE(mytype_get_data(obj1), mytype_get_data(obj2), op);
... you use it like this:
PY_RETURNRICHCOMPARE(mytype_get_data(obj1), mytype_get_data(obj2), op);
More information about the Python-ideas
mailing list