mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
gh-84436: Implement Immortal Objects (gh-19474)
This is the implementation of PEP683 Motivation: The PR introduces the ability to immortalize instances in CPython which bypasses reference counting. Tagging objects as immortal allows up to skip certain operations when we know that the object will be around for the entire execution of the runtime. Note that this by itself will bring a performance regression to the runtime due to the extra reference count checks. However, this brings the ability of having truly immutable objects that are useful in other contexts such as immutable data sharing between sub-interpreters.
This commit is contained in:
parent
916de04fd1
commit
ea2c001650
35 changed files with 483 additions and 171 deletions
30
Python/clinic/sysmodule.c.h
generated
30
Python/clinic/sysmodule.c.h
generated
|
@ -912,6 +912,34 @@ exit:
|
|||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(sys_getunicodeinternedsize__doc__,
|
||||
"getunicodeinternedsize($module, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return the number of elements of the unicode interned dictionary");
|
||||
|
||||
#define SYS_GETUNICODEINTERNEDSIZE_METHODDEF \
|
||||
{"getunicodeinternedsize", (PyCFunction)sys_getunicodeinternedsize, METH_NOARGS, sys_getunicodeinternedsize__doc__},
|
||||
|
||||
static Py_ssize_t
|
||||
sys_getunicodeinternedsize_impl(PyObject *module);
|
||||
|
||||
static PyObject *
|
||||
sys_getunicodeinternedsize(PyObject *module, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t _return_value;
|
||||
|
||||
_return_value = sys_getunicodeinternedsize_impl(module);
|
||||
if ((_return_value == -1) && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = PyLong_FromSsize_t(_return_value);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(sys__getframe__doc__,
|
||||
"_getframe($module, depth=0, /)\n"
|
||||
"--\n"
|
||||
|
@ -1387,4 +1415,4 @@ exit:
|
|||
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
|
||||
#define SYS_GETANDROIDAPILEVEL_METHODDEF
|
||||
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
|
||||
/*[clinic end generated code: output=5c761f14326ced54 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=6d598acc26237fbe input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue