| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Changing this to a draft. See a separated PR: #117189. |
Sorry, something went wrong.
| */ | ||
|
|
||
| /*[clinic input] | ||
| class _ctypes.PyCPointerType "PyObject *" "st->PyCPointerType_Type" |
There was a problem hiding this comment.
FWIW, I've used the practice of defining a "clinic state" macro for getting the module state in generated clinic code. It has proven useful if you want to tweak stuff afterwards (smaller diffs, less churn). You can git grep clinic_state **/*.c for inspiration.
Sorry, something went wrong.
There was a problem hiding this comment.
IIUC, *_impl() should be passed a module state if the AC gets it in advance with some overhead. Also, _ctypes would need a module state getter to be specified in each function clinic input, making a class input have a type name without any operator, EDIT: or making the getter return st.
Sorry, something went wrong.
There was a problem hiding this comment.
Ah, _PyType_GetModuleState(cls) or _PyType_GetModuleState(cls->tp_base) can be applied to each class. I'll try.
Sorry, something went wrong.
|
Is it acceptable to optimize PyType_GetModuleByDef (limited API) by checking the given type before the MRO walk? This PR passes C-API types to it in almost all cases. The tuning in _ctypes (outside PyType_GetModuleByDef) would be fine as well, which should be inlined. I would prefer the former, though. |
Sorry, something went wrong.
I seem to recall it had such an optimization at some point. I'm not sure why it's not there now; perhaps we simply went with simpler code in the first PR. If you can measure the speedup, definitely add it :) |
Sorry, something went wrong.
There was a problem hiding this comment.
This looks amazing, thank you!
I found one more snag, other than that it looks like we're almost home.
Sorry, something went wrong.
|
And back to optimizing PyType_GetModuleByDef, So it seems the current code isn't quite carefully tuned, feel free to make it faster. (But note that getting a type's MRO and getting an item from a tuple should be very fast already.) |
Sorry, something went wrong.
Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
Regarding PyType_GetModuleByDef, I've applied optimization at #117661, which is not beneficial for the getset of ctypes. _decimal got around 7% faster in some cases with noises. |
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you!
Sorry, something went wrong.
|
Thank you very much for the review. |
Sorry, something went wrong.
|
Good job! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Port _ctypes to multi-phase init with the module state enabled.
Module state access: