Skip to content
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-117398: datetime: Make use of C-API capsules for sub-interpreters #117413

Closed
wants to merge 16 commits into from

Conversation

neonene
Copy link
Contributor

@neonene neonene commented Apr 1, 2024

Allow sub-interpreters to access their C-API by calling PyCapsule_Import function every time. Performance could be recovered by client's local caching. The _zoneinfo extension could also improve a few C-API accesses, if necessary.

UPDATE: Tuned for a sub-interpreter: #117413 (comment)

cc @erlend-aasland @ericsnowcurrently

Include/datetime.h Outdated Show resolved Hide resolved
Include/datetime.h Outdated Show resolved Hide resolved
@ericsnowcurrently
Copy link
Member

I'm especially interested to know what @pganssle thinks.

@neonene
Copy link
Contributor Author

neonene commented Apr 10, 2024

#117498 is a demo version of _datetime isolated with this way, which I think does not conflict with long-term approaches.

cc @pganssle

@neonene
Copy link
Contributor Author

neonene commented May 1, 2024

I have made this the same as #118357 except that this PR caches capi-pointers in the global C array rather than PyInterpreterState. One subinterpreter can use the global variable for now, so PyCapsule_Import will be called when multiple subinterpreters use the _datetime module at the same time.

neonene added a commit to neonene/cpython that referenced this pull request May 4, 2024
@neonene neonene closed this May 23, 2024
@neonene neonene deleted the capsule branch May 23, 2024 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants