Py_IS_TYPE() macro uses Py_TYPE()#22341
Py_IS_TYPE() macro uses Py_TYPE()#22341vstinner merged 1 commit intopython:masterfrom vstinner:Py_IS_TYPE
Conversation
|
|
||
|
|
||
| static inline int _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) { | ||
| return ob->ob_type == type; |
There was a problem hiding this comment.
Hm, There have any benefit from this change?
There was a problem hiding this comment.
My plan is to hide implementation details as much as possible: https://www.python.org/dev/peps/pep-0620/
Right now, Py_TYPE() is trivial: just read ob->ob_type, but it may be more complex tomorrow.
Example in my tagged pointer experiment:
https://github.com/vstinner/cpython/blob/tagged_ptr/Include/object.h#L203
static inline PyTypeObject* _Py_TYPE(const PyObject *ob)
{
if (!_Py_TAGPTR_IS_TAGGED(ob)) {
return ob->ob_type;
}
else {
return _Py_TAGPTR_TYPE(ob);
}
}
Experiment: vstinner#6
There was a problem hiding this comment.
With this PR, only Py_TYPE() has to be updated, Py_IS_TYPE() remains unchanged.
|
Thanks for your reviews @shihai1991 and @corona10 ;-) If you are curious about tagged pointers: https://mail.python.org/archives/list/[email protected]/thread/4ETF7H5COIZWTCXDRTITVMU4P5DLRDLU/ |
copy that, this is an interesting PR. |
No description provided.