mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-24 23:07:00 +00:00
Add support for array_t<handle> and array_t<object> (#5427)
* Add support for array_t<handle> and array_t<object>
* style: pre-commit fixes
* Remove loops that aren't strictly needed
* Fix compiler warning
* Disable GC-dependent checks when running on pypy or graalpy
* style: pre-commit fixes
* Remove PyValueHolder counter again
* Move tests to templates to avoid code duplication
* Rerun pre-commit
* Restore import that was erroneously removed by pre-commit
* Reduce code duplication with more template magic
* Bring back `.attr("value")` in `return_array_cpp_loop()`
This was meant to further stress-test correctness of refcount handling.
All modified test functions were manually leak-checked (`while True`, top command, Python 3.12.3, Ubuntu 24.01, gcc 13.2.0).
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
This commit is contained in:
@@ -1428,7 +1428,11 @@ public:
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct npy_format_descriptor<T, enable_if_t<is_same_ignoring_cvref<T, PyObject *>::value>> {
|
||||
struct npy_format_descriptor<
|
||||
T,
|
||||
enable_if_t<is_same_ignoring_cvref<T, PyObject *>::value
|
||||
|| ((std::is_same<T, handle>::value || std::is_same<T, object>::value)
|
||||
&& sizeof(T) == sizeof(PyObject *))>> {
|
||||
static constexpr auto name = const_name("object");
|
||||
|
||||
static constexpr int value = npy_api::NPY_OBJECT_;
|
||||
|
||||
Reference in New Issue
Block a user