Added len() function

This commit is contained in:
Wenzel Jakob 2016-04-13 22:48:05 +02:00
parent 1a060fd70d
commit 5a6aa49105
1 changed files with 7 additions and 0 deletions

View File

@ -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)