GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-117142: Port _ctypes to multi-phase init by neonene · Pull Request #117181 · python/cpython Conversation
|
| From | access | |
|---|---|---|
| ctype | PyType_GetModuleByDef(Py_TYPE(type)) |
|
| cdata | PyType_GetModuleByDef(Py_TYPE(Py_TYPE(obj))) |
|
| CFieldObject | _PyType_GetModuleState(Py_TYPE(obj)) |
Internal |
| CThunkObject | _PyType_GetModuleState(Py_TYPE(obj)) |
Internal |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Changing this to a draft. See a separated PR: #117189. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| */ | ||
|
|
||
| /*[clinic input] | ||
| class _ctypes.PyCPointerType "PyObject *" "st->PyCPointerType_Type" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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 an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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 an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ah, _PyType_GetModuleState(cls) or _PyType_GetModuleState(cls->tp_base) can be applied to each class. I'll try.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Is it acceptable to optimize |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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 an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This looks amazing, thank you!
I found one more snag, other than that it looks like we're almost home.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
And back to optimizing 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.
There was an error while loading. Please reload this page.
Co-authored-by: Petr Viktorin <[email protected]>
|
Regarding |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you very much for the review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Good job! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.