MCPcopy Create free account
hub / github.com/pybind/pybind11 / len_hint

Function len_hint

include/pybind11/pytypes.h:2561–2570  ·  view source on GitHub ↗

Get the length hint of a Python object. Returns 0 when this cannot be determined.

Source from the content-addressed store, hash-verified

2559/// Get the length hint of a Python object.
2560/// Returns 0 when this cannot be determined.
2561inline size_t len_hint(handle h) {
2562 ssize_t result = PyObject_LengthHint(h.ptr(), 0);
2563 if (result < 0) {
2564 // Sometimes a length can't be determined at all (eg generators)
2565 // In which case simply return 0
2566 PyErr_Clear();
2567 return 0;
2568 }
2569 return static_cast<size_t>(result);
2570}
2571
2572inline str repr(handle h) {
2573 PyObject *str_value = PyObject_Repr(h.ptr());

Callers 1

vector_modifiersFunction · 0.85

Calls 1

ptrMethod · 0.80

Tested by

no test coverage detected