diff options
author | Eddie Elizondo <eduardo.elizondorueda@gmail.com> | 2023-04-22 15:39:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-22 13:39:37 -0600 |
commit | ea2c0016502472aa8baa3149050ada776d17a009 (patch) | |
tree | e9e3935a9b71a1f88ac18c24fe512d199880ff90 /Python/sysmodule.c | |
parent | 916de04fd1838530096336aadb3b94b774ed6c90 (diff) | |
download | cpython-git-ea2c0016502472aa8baa3149050ada776d17a009.tar.gz |
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.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 4d693a1be1..1e42e8dfce 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1874,6 +1874,18 @@ sys_getallocatedblocks_impl(PyObject *module) return _Py_GetAllocatedBlocks(); } +/*[clinic input] +sys.getunicodeinternedsize -> Py_ssize_t + +Return the number of elements of the unicode interned dictionary +[clinic start generated code]*/ + +static Py_ssize_t +sys_getunicodeinternedsize_impl(PyObject *module) +/*[clinic end generated code: output=ad0e4c9738ed4129 input=726298eaa063347a]*/ +{ + return _PyUnicode_InternedSize(); +} /*[clinic input] sys._getframe @@ -2243,6 +2255,7 @@ static PyMethodDef sys_methods[] = { SYS_GETDEFAULTENCODING_METHODDEF SYS_GETDLOPENFLAGS_METHODDEF SYS_GETALLOCATEDBLOCKS_METHODDEF + SYS_GETUNICODEINTERNEDSIZE_METHODDEF SYS_GETFILESYSTEMENCODING_METHODDEF SYS_GETFILESYSTEMENCODEERRORS_METHODDEF #ifdef Py_TRACE_REFS |