Short version
I recently came across some Python code in which the return type for a function was specified as PyObject
in the document
A PyObject
is in fact just a Python object at the C level. And since integers in Python are objects, they are also PyObject
s. It doesn't matter whether it was written in Python or in C, it is a PyObject
at the C level regardless.
Every value you can touch in Python is a PyObject
in C. That includes lists, dictionaries, sockets, files, integers, strings, functions, classes, you name it. If you can touch it in Python, it’s a PyObject
in C.