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
gh-90763: Modernise xx template module initialisation #93078
base: main
Are you sure you want to change the base?
Conversation
Use C APIs such as PyModule_AddType instead of PyModule_AddObject. Also remove incorrect module decrefs if module fails to initialise.
@corona10, would you mind reviewing this? It's been a while since I've done the module init ref count dances :) I note that xxlimited_35 creates two objects from the same type spec. I'm not sure if there's a point in doing that. |
Thanks, Dong-hee! I'll hold the merge a couple of days to give Petr (or Victor) a chance to review. |
Looks good, thanks! |
I had to ponder a little bit about this; I agree that it's worth it keeping the changes minimal for these modules :) |
The file starts with:
IMO it should be a show case of the best practice to write a C extension in 2022. Otherwise, people will continue to copy/paste this old code and will propagate static types and other legacy code to their project :-( |
If you want to test that the old way to write a C extension, with static types and global variables, still work, IMO it should be another module than this "template". |
We could adjust the wording in the top of the file, and also rename it to something like
That's what the xxlimited.c module is :) |
xxmodule:
xxlimited_35: