3

I've been learning about Cython recently. I'm still a beginner, but I'm excited about the prospect of using it in the future.

In my mind, Cython has two main uses:

  1. Making Cython or C/C++ functions accessible from Python. See: Calling C functions.

    • You can expose Cython and C/C++ functions to Python by making a Cython module extension using setuptools.
  2. Making Cython or Python functions accessible from C/C++. See: Embedding Cython modules in C/C++ applications.

    • You can expose Cython and Python functions to C/C++ by embedding the Python interpreter into your C/C++ application using Py_Initialize and company.

What if you want to do both of these things for the same project?

Is there a way to use Cython to create a shared object (.so) file which can both be imported as a Python module, and linked against from C/C++?

Christopher Peisert
  • 21,862
  • 3
  • 86
  • 117
JacKeown
  • 2,780
  • 7
  • 26
  • 34
  • 1
    I know it is possible via SIP and some frameorks like Qt provide this. But I don’t know about Cython – Iman Nia Oct 25 '20 at 01:00
  • 2
    I think this should work fine. Just follow the instructions for both parts. I don't they they contradict each other. – DavidW Oct 25 '20 at 07:55

0 Answers0