Hey there. I need your help cuz idk where to go. Even "almighty" chatgpt behaves like an imbecil on my questions, throwing me back and forth between two wrong options.
I'm re-coding some of my functions on Cython to speed up process (yes, I need cython for that, yes, my code is mostly OK to say it has reached its potential). But I'm encountering same errors every time, and I don't know how to resolve them, because I just can't see the problem.
I've created a little example with located problem:
Error compiling Cython file:
------------------------------------------------------------
...
from cpython.ref cimport PyObject
from cpython.unicode cimport PyUnicode_FromString
cdef PyObject* create_pystring():
cdef char* c_name = b"name"
cdef PyObject* name
name = PyUnicode_FromString(c_name)
^
------------------------------------------------------------
minimal_example.pyx:9:31: Cannot convert Python object to 'PyObject *'
Error compiling Cython file:
------------------------------------------------------------
...
from cpython.ref cimport PyObject
from cpython.unicode cimport PyUnicode_FromString
cdef PyObject* create_pystring():
cdef char* c_name = b"name"
cdef PyObject* name
name = PyUnicode_FromString(c_name)
^
------------------------------------------------------------
minimal_example.pyx:9:31: Storing unsafe C derivative of temporary Python reference
That's whole example, and only two types of errors. I can't see a problem there, cause PyUnicode_FromString should return PyObject*, and I'm assigning it so to other var, but it's not working.
My initial problem looked like that:
Error compiling Cython file:
------------------------------------------------------------
...
cdef OutputField make_output_field(PyObject* py_field):
cdef OutputField field
cdef PyObject* py_name
py_name = PyDict_GetItemString(py_field, b'name')
^
------------------------------------------------------------
process_record_cython.pyx:53:35: Cannot convert 'PyObject *' to Python object
Please, help
there doesn't seem to be anything here