Commit 5a6aa491 by Wenzel Jakob

Added len() function

parent 1a060fd7
...@@ -461,4 +461,11 @@ public: ...@@ -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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment