hash
in python is implemented with PyObject_Hash
on the C side of things. If you have a random object obj
, you can simply call:
long hash = PyObject_Hash(obj.ptr())
The ptr()
method on a boost::python::object
returns a PyObject *
that has a borrowed reference to that object.
In general, there's tons of stuff in the CPython API that is not wrapped by boost::python. It's easy enough to just call it directly.