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 /Programs | |
| 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 'Programs')
| -rw-r--r-- | Programs/_testembed.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c index 00717114b4..f78ba41fe7 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -1911,14 +1911,13 @@ static int test_unicode_id_init(void) str1 = _PyUnicode_FromId(&PyId_test_unicode_id_init); assert(str1 != NULL); - assert(Py_REFCNT(str1) == 1); + assert(_Py_IsImmortal(str1)); str2 = PyUnicode_FromString("test_unicode_id_init"); assert(str2 != NULL); assert(PyUnicode_Compare(str1, str2) == 0); - // str1 is a borrowed reference Py_DECREF(str2); Py_Finalize(); |
