-
-
Couldn't load subscription status.
- Fork 33.3k
gh-118965: Share NotImplemented in subinterpreters
#118966
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Added support for sharing ``NotImplemented`` singleton with subinterpreters. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -435,6 +435,23 @@ _none_shared(PyThreadState *tstate, PyObject *obj, | |
| return 0; | ||
| } | ||
|
|
||
| // NotImplemented | ||
|
|
||
| static PyObject * | ||
| _new_notimplemented_object(_PyCrossInterpreterData *data) | ||
| { | ||
| return Py_NewRef(Py_NotImplemented); | ||
sobolevn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| static int | ||
| _notimplemented_shared(PyThreadState *tstate, PyObject *obj, | ||
| _PyCrossInterpreterData *data) | ||
| { | ||
| _PyCrossInterpreterData_Init(data, tstate->interp, NULL, NULL, | ||
| _new_notimplemented_object); | ||
| return 0; | ||
| } | ||
|
|
||
| // bool | ||
|
|
||
| static PyObject * | ||
|
|
@@ -562,6 +579,13 @@ _register_builtins_for_crossinterpreter_data(struct _xidregistry *xidregistry) | |
| Py_FatalError("could not register None for cross-interpreter sharing"); | ||
| } | ||
|
|
||
| // NotImplemented | ||
| if (_xidregistry_add_type(xidregistry, | ||
| (PyTypeObject *)PyObject_Type(Py_NotImplemented), | ||
| _notimplemented_shared) != 0) { | ||
| Py_FatalError("could not register NotImplemented for cross-interpreter sharing"); | ||
| } | ||
|
Comment on lines
+588
to
+593
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we generalize this with a macro? (Future refactoring) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so. Last I heard, Eric's plan was to eventually get a dedicated type slot for crossinterpreter registry things, so this will (hopefully) be obsolete sooner than later. |
||
|
|
||
| // int | ||
| if (_xidregistry_add_type(xidregistry, &PyLong_Type, _long_shared) != 0) { | ||
| Py_FatalError("could not register int for cross-interpreter sharing"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.