title: Python - Convert PyInt into C int
body: <p>i'm currently facing a problem when trying to retrieve the value returned by my python code.</p>
  
  <p>A draft of my code is : </p>
  
  <pre><code># I call a function that returns a PyObject
  PyObject* pyObj_val = call_binding(...);
  
  # This PyObject seems to be a PyInt as PyInt_Check returns 1
  assert(PyInt_Check(pyObj_val) == 1);
  
  # Now the only way i found to convert this PyInt to a [C] int is:
  int my_val = (int) PyInt_AsLong(pyObj_val);
  </code></pre>
  
  <p>I suppose there is a way to perform this without going through a long convertion and int cast. Does anyone know about it ?</p>
  
  <p>Thanks for considering my request.</p>