Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-117398: Isolate _datetime (3.13.0a6 PoC) #117498

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

Closed
wants to merge 27 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PyCapsule_Import() every time for subinterp
  • Loading branch information
neonene committed Apr 3, 2024
commit bfab79f60c6165f7931d1f4cad272e2d5f623787
20 changes: 17 additions & 3 deletions 20 Include/datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,24 @@ typedef struct {
* */
#ifndef _PY_DATETIME_IMPL
/* Define global variable for the C API and a macro for setting it. */
static PyDateTime_CAPI *PyDateTimeAPI = NULL;
static PyDateTime_CAPI *_pydatetimeapi_main = NULL;

#define PyDateTime_IMPORT \
PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0)
static inline void _import_pydatetime(void) {
if (PyInterpreterState_Get() == PyInterpreterState_Main()) {
_pydatetimeapi_main = PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0);
}
}
#define PyDateTime_IMPORT _import_pydatetime()

static inline PyDateTime_CAPI *_get_pydatetime_api(void) {
if (PyInterpreterState_Get() == PyInterpreterState_Main()) {
return _pydatetimeapi_main;
}
else {
return PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0);
}
}
#define PyDateTimeAPI _get_pydatetime_api()

/* Macro for access to the UTC singleton */
#define PyDateTime_TimeZone_UTC PyDateTimeAPI->TimeZone_UTC
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.