Added len() function
diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h
index 455d893..e23df9a 100644
--- a/include/pybind11/pytypes.h
+++ b/include/pybind11/pytypes.h
@@ -461,4 +461,11 @@
     }
 };
 
+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)