diff options
author | Victor Stinner <vstinner@python.org> | 2021-06-03 16:42:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 16:42:59 (GMT) |
commit | f3fa63ec75fdbb4a08a10957a5c631bf0c4a5970 (patch) | |
tree | 7e87d8e48debfad12ff2cd79637ca1eb03af6ca0 /Include | |
parent | d88b47b5a396aa8d66f9a0e6b13a0825d59d0eff (diff) | |
download | cpython-f3fa63ec75fdbb4a08a10957a5c631bf0c4a5970.zip cpython-f3fa63ec75fdbb4a08a10957a5c631bf0c4a5970.tar.gz cpython-f3fa63ec75fdbb4a08a10957a5c631bf0c4a5970.tar.bz2 |
bpo-39573: Py_TYPE becomes a static inline function (GH-26493)
Convert the Py_TYPE() and Py_SIZE() macros to static inline
functions. The Py_SET_TYPE() and Py_SET_SIZE() functions must now be
used to set an object type and size.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/object.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Include/object.h b/Include/object.h index 4c06999..a3b5d0d 100644 --- a/Include/object.h +++ b/Include/object.h @@ -134,10 +134,16 @@ static inline Py_ssize_t _Py_REFCNT(const PyObject *ob) { // bpo-39573: The Py_SET_TYPE() function must be used to set an object type. -#define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type) +static inline PyTypeObject* _Py_TYPE(const PyObject *ob) { + return ob->ob_type; +} +#define Py_TYPE(ob) _Py_TYPE(_PyObject_CAST_CONST(ob)) // bpo-39573: The Py_SET_SIZE() function must be used to set an object size. -#define Py_SIZE(ob) (_PyVarObject_CAST(ob)->ob_size) +static inline Py_ssize_t _Py_SIZE(const PyVarObject *ob) { + return ob->ob_size; +} +#define Py_SIZE(ob) _Py_SIZE(_PyVarObject_CAST_CONST(ob)) static inline int _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) { |