[docs] [issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

Eric Snow report at bugs.python.org
Sat Mar 30 01:29:36 CET 2013

Eric Snow added the comment:

Would it be okay to do a check on __index__ after the PyLong_Check() succeeds?  Something like this:

    if (PyLong_Check(item) &&
        item->ob_type->tp_as_number->nb_index == PyLong_Type.tp_as_number->nb_index) {
        return item;

This is something Nick and I were talking about at the sprints regarding fast paths in the abstract API (for mappings and sequences in our case).

nosy: +eric.snow

Python tracker <report at bugs.python.org>

More information about the docs mailing list