-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
Problem description
Python 3.9 to Python 3.10 changed this code:
#define PyObject_TypeCheck(ob, tp) \
(Py_IS_TYPE(ob, tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
to this code:
static inline int _PyObject_TypeCheck(PyObject *ob, PyTypeObject *type) {
return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);
}
#define PyObject_TypeCheck(ob, type) _PyObject_TypeCheck(_PyObject_CAST(ob), type)
That change gives two c4800 warnings here:
bool PyArray_Check_(PyObject *obj) const {
return (bool) PyObject_TypeCheck(obj, PyArray_Type_);
}
bool PyArrayDescr_Check_(PyObject *obj) const {
return (bool) PyObject_TypeCheck(obj, PyArrayDescr_Type_);
}
pybind11/numpy.h(173): warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning)
pybind11/numpy.h(176): warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning)
Consider changing to something like this given you've done similar fixes:
bool PyArray_Check_(PyObject *obj) const {
return PyObject_TypeCheck(obj, PyArray_Type_) != 0;
}
bool PyArrayDescr_Check_(PyObject *obj) const {
return PyObject_TypeCheck(obj, PyArrayDescr_Type_) != 0;
}
P.S. I'm sorry this is not a PR. But I don't wanna set up everything for such a small change
Reproducible example code
No response