diff options
author | Eddie Elizondo <eduardo.elizondorueda@gmail.com> | 2023-04-22 19:39:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-22 19:39:37 (GMT) |
commit | ea2c0016502472aa8baa3149050ada776d17a009 (patch) | |
tree | e9e3935a9b71a1f88ac18c24fe512d199880ff90 /Include/boolobject.h | |
parent | 916de04fd1838530096336aadb3b94b774ed6c90 (diff) | |
download | cpython-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 'Include/boolobject.h')
-rw-r--r-- | Include/boolobject.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Include/boolobject.h b/Include/boolobject.h index ca21fbf..976fa35 100644 --- a/Include/boolobject.h +++ b/Include/boolobject.h @@ -11,8 +11,7 @@ PyAPI_DATA(PyTypeObject) PyBool_Type; #define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type) -/* Py_False and Py_True are the only two bools in existence. -Don't forget to apply Py_INCREF() when returning either!!! */ +/* Py_False and Py_True are the only two bools in existence. */ /* Don't use these directly */ PyAPI_DATA(PyLongObject) _Py_FalseStruct; @@ -31,8 +30,8 @@ PyAPI_FUNC(int) Py_IsFalse(PyObject *x); #define Py_IsFalse(x) Py_Is((x), Py_False) /* Macros for returning Py_True or Py_False, respectively */ -#define Py_RETURN_TRUE return Py_NewRef(Py_True) -#define Py_RETURN_FALSE return Py_NewRef(Py_False) +#define Py_RETURN_TRUE return Py_True +#define Py_RETURN_FALSE return Py_False /* Function to return a bool from a C long */ PyAPI_FUNC(PyObject *) PyBool_FromLong(long); |