New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
study alternatives to PyType_IsSubtype #1132
Comments
scoder changed owner from |
scoder changed description from This is an old ticket from the Sage Trac which more appropriately belongs here: Lots of our Pyrex code is going to be using PyObject_TypeCheck as a replacement for isinstance. This is a C macro (defined in python's object.h file), HOWEVER if the types don't match exactly it has to call the API PyType?_IsSubType. The code for that function is shown below. Probably we can write something somewhat faster that covers many of the situations we need, because we don't need to worry about the MRO (method resolution order) stuff.
to This is an old ticket from the Sage Trac which more appropriately belongs here: Lots of our Pyrex code is going to be using
commented This code looks very fast and cache efficient. It basically runs through the array of pointers that underlies the MRO tuple and compares the pointers with the type pointer in question. The MRO tuple should usually fit into a single cache line, so the whole algorithm should finish within a few CPU cycles for reasonably sized inheritance hierarchies. Is there any special case that you want to see optimised? Otherwise, I don't think there's much you could do better. |
scoder changed cc to |
scoder changed keywords to |
scoder changed resolution to Closing this since there hasn't been any further interest and it's not clear why this is supposed to be a problem. |
@robertwb changed milestone from |
This is an old ticket from the Sage Trac which more appropriately belongs here:
Lots of our Pyrex code is going to be using
PyObject_TypeCheck
as a replacement for isinstance. This is a C macro (defined in python's object.h file), HOWEVER if the types don't match exactly it has to call the APIPyType?_IsSubType
. The code for that function is shown below. Probably we can write something somewhat faster that covers many of the situations we need, because we don't need to worry about the MRO (method resolution order) stuff.Migrated from http://trac.cython.org/ticket/572
The text was updated successfully, but these errors were encountered: