File tree 3 files changed +11
-5
lines changed
Misc/NEWS.d/next/Core and Builtins
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.
62
62
See documentation of :c:type: `PyVarObject ` above.
63
63
64
64
65
- .. c :macro :: Py_TYPE(o)
65
+ .. c :function :: PyTypeObject* Py_TYPE (PyObject * o)
66
66
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.
69
68
70
- (((PyObject*)(o))->ob_type)
69
+ .. versionchanged :: 3.10
70
+ :c:func: `Py_TYPE() ` is changed to the inline static function.
71
71
72
72
73
73
.. 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 {
121
121
#define _PyVarObject_CAST (op ) ((PyVarObject*)(op))
122
122
123
123
#define Py_REFCNT (ob ) (_PyObject_CAST(ob)->ob_refcnt)
124
- #define Py_TYPE (ob ) (_PyObject_CAST(ob)->ob_type)
125
124
#define Py_SIZE (ob ) (_PyVarObject_CAST(ob)->ob_size)
126
125
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
+
127
131
static inline int _Py_IS_TYPE (const PyObject * ob , const PyTypeObject * type ) {
128
132
return ob -> ob_type == type ;
129
133
}
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