title: What is a PyObject in Python?
body: <p><strong>Short version</strong></p>
  
  <p>I recently came across some Python code in which the return type for a function was specified as <code>PyObject</code> in <a href="https://srinikom.github.io/pyside-docs/PySide/QtCore/QSize.html#PySide.QtCore.PySide.QtCore.QSize.__reduce__" rel="noreferrer">the documentation</a>. What is a <code>PyObject</code>?</p>
  
  <p><strong>Detailed version</strong></p>
  
  <p>I am not a C/C++ programmer, but when I ran into <code>PyObject</code> in the documentation linked above, Google taught me that <code>PyObject</code> is a Python object as defined using the Python/C API. Specifically, the <a href="https://docs.python.org/2/c-api/structures.html#c.PyObject" rel="noreferrer">API documentation</a> defines PyObject as follows:</p>
  
  <blockquote>
    <p>All object types are extensions of this type. This is a type which
    contains the information Python needs to treat a pointer to an object
    as an object. In a normal “release” build, it contains only the
    object’s reference count and a pointer to the corresponding type
    object. It corresponds to the fields defined by the expansion of the
    PyObject_HEAD macro.</p>
  </blockquote>
  
  <p>Frankly, I don't fully understand this, or whether it answers my basic question, but it doesn't make me think it is obviously wrong to just think of a <code>PyObject</code> as a Python object, full stop. On the other hand, perhaps to technically count as a <code>PyObject</code> the type must have been created as an extension to standard Python using the Python/C API. For instance, is an integer a <code>PyObject</code>?</p>
  
  <p><strong>Potentially relevant links</strong></p>
  
  <p><a href="http://docs.scipy.org/doc/numpy/reference/c-api.types-and-structures.html" rel="noreferrer">http://docs.scipy.org/doc/numpy/reference/c-api.types-and-structures.html</a></p>