File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed
Misc/NEWS.d/next/Core and Builtins Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -62,12 +62,12 @@ the definition of all other Python objects.
6262 See documentation of :c:type: `PyVarObject ` above.
6363
6464
65- .. c :macro :: Py_TYPE(o)
65+ .. c :function :: PyTypeObject* Py_TYPE (PyObject * o)
6666
67- This macro is used to access the :attr: `ob_type ` member of a Python object.
68- It expands to::
67+ This function is used to access the :attr: `ob_type ` member of a Python object.
6968
70- (((PyObject*)(o))->ob_type)
69+ .. versionchanged :: 3.10
70+ :c:func: `Py_TYPE() ` is changed to the inline static function.
7171
7272
7373.. c :function :: int Py_IS_TYPE (PyObject *o, PyTypeObject *type)
Original file line number Diff line number Diff line change @@ -121,9 +121,13 @@ typedef struct {
121121#define _PyVarObject_CAST (op ) ((PyVarObject*)(op))
122122
123123#define Py_REFCNT (ob ) (_PyObject_CAST(ob)->ob_refcnt)
124- #define Py_TYPE (ob ) (_PyObject_CAST(ob)->ob_type)
125124#define Py_SIZE (ob ) (_PyVarObject_CAST(ob)->ob_size)
126125
126+ static inline PyTypeObject * _Py_TYPE (const PyObject * ob ) {
127+ return ob -> ob_type ;
128+ }
129+ #define Py_TYPE (ob ) _Py_TYPE(_PyObject_CAST_CONST(ob))
130+
127131static inline int _Py_IS_TYPE (const PyObject * ob , const PyTypeObject * type ) {
128132 return ob -> ob_type == type ;
129133}
Original file line number Diff line number Diff line change 1+ :c:func: `Py_TYPE() ` is changed to the inline static function. Patch by
2+ Dong-hee Na.
You can’t perform that action at this time.
0 commit comments