from cpython.ref cimport PyObject cdef extern from *: ctypedef Py_ssize_t Py_intptr_t python_string = "foo" cdef void* ptr = python_string cdef Py_intptr_t adress_in_c = ptr address_from_void = adress_in_c # address_from_void is a python int cdef PyObject* ptr2 = python_string cdef Py_intptr_t address_in_c2 = ptr2 address_from_PyObject = address_in_c2 # address_from_PyObject is a python int assert address_from_void == address_from_PyObject == id(python_string) print(ptr) # Prints "foo" print(ptr2) # prints "foo"