summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorEddie Elizondo <eduardo.elizondorueda@gmail.com>2023-04-22 19:39:37 (GMT)
committerGitHub <noreply@github.com>2023-04-22 19:39:37 (GMT)
commitea2c0016502472aa8baa3149050ada776d17a009 (patch)
treee9e3935a9b71a1f88ac18c24fe512d199880ff90 /Doc
parent916de04fd1838530096336aadb3b94b774ed6c90 (diff)
downloadcpython-ea2c0016502472aa8baa3149050ada776d17a009.zip
cpython-ea2c0016502472aa8baa3149050ada776d17a009.tar.gz
cpython-ea2c0016502472aa8baa3149050ada776d17a009.tar.bz2
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 'Doc')
-rw-r--r--Doc/library/sys.rst7
-rw-r--r--Doc/whatsnew/3.12.rst21
2 files changed, 26 insertions, 2 deletions
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index e37d57e..7324f31 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -670,6 +670,13 @@ always available.
.. versionadded:: 3.4
+.. function:: getunicodeinternedsize()
+
+ Return the number of unicode objects that have been interned.
+
+ .. versionadded:: 3.12
+
+
.. function:: getandroidapilevel()
Return the build time API version of Android as an integer.
diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst
index f940665..b98b715 100644
--- a/Doc/whatsnew/3.12.rst
+++ b/Doc/whatsnew/3.12.rst
@@ -1129,6 +1129,24 @@ New Features
to replace the legacy-api :c:func:`!PyErr_Display`. (Contributed by
Irit Katriel in :gh:`102755`).
+* :pep:`683`: Introduced Immortal Objects to Python which allows objects
+ to bypass reference counts and introduced changes to the C-API:
+
+ - ``_Py_IMMORTAL_REFCNT``: The reference count that defines an object
+ as immortal.
+ - ``_Py_IsImmortal`` Checks if an object has the immortal reference count.
+ - ``PyObject_HEAD_INIT`` This will now initialize reference count to
+ ``_Py_IMMORTAL_REFCNT`` when used with ``Py_BUILD_CORE``.
+ - ``SSTATE_INTERNED_IMMORTAL`` An identifier for interned unicode objects
+ that are immortal.
+ - ``SSTATE_INTERNED_IMMORTAL_STATIC`` An identifier for interned unicode
+ objects that are immortal and static
+ - ``sys.getunicodeinternedsize`` This returns the total number of unicode
+ objects that have been interned. This is now needed for refleak.py to
+ correctly track reference counts and allocated blocks
+
+ (Contributed by Eddie Elizondo in :gh:`84436`.)
+
Porting to Python 3.12
----------------------
@@ -1293,8 +1311,7 @@ Removed
* :c:func:`!PyUnicode_GetSize`
* :c:func:`!PyUnicode_GET_DATA_SIZE`
-* Remove the ``PyUnicode_InternImmortal()`` function and the
- ``SSTATE_INTERNED_IMMORTAL`` macro.
+* Remove the ``PyUnicode_InternImmortal()`` function macro.
(Contributed by Victor Stinner in :gh:`85858`.)
* Remove ``Jython`` compatibility hacks from several stdlib modules and tests.