I am interested in passing data between Python and Cython code so that the data are accessible from C and without GIL. I am thinking about achieving this using dataclasses (since py3.7), named tuples (with nice defining syntax since py3.6) or Cython's extension types (cdef classess).
Unfortunately, dataclasses and named tuples seem to be handled like generic objects from Cython without any support of being compiled into C.
Cython extension types (cdef classes) can be used, but they have many disadvantages compared to dataclasses, most importantly you have to implement __init__
with boilerplate code for setting all your class attributes, right?
I asked Cython developers and they opened a feature request for implementing @dataclass
for extension types (cdef classes): https://github.com/cython/cython/issues/2903. So hopefully they will be supported in Cython soon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With