mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 14:45:12 +00:00
Added len() function
This commit is contained in:
parent
1a060fd70d
commit
5a6aa49105
@ -461,4 +461,11 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline size_t len(handle h) {
|
||||||
|
ssize_t result = PyObject_Length(h.ptr());
|
||||||
|
if (result < 0)
|
||||||
|
pybind11_fail("Unable to compute length of object");
|
||||||
|
return (size_t) result;
|
||||||
|
}
|
||||||
|
|
||||||
NAMESPACE_END(pybind11)
|
NAMESPACE_END(pybind11)
|
||||||
|
Loading…
Reference in New Issue
Block a user