简体   繁体   中英

how to build whole python project with cython

I have a PySide project with many modules, files and folders. I also used Numpy, Matplotlib and many other modules.

I want to build this project with cython. The code is pure python, and i want cython to add all dependencies together, just like when using pyinstaller

is it possible or cython is just made for writing extensions (dll, so, lib) ?

You can Cythonize your modules file by file if you want to, however all the dependencies will remain the way they are in Python. Cython does not provide a mechanism to embedd all the required modules the way pyinstaller does.

This is, however, a bad idea. The general approach for optimization in scientific python is that we port to Cython/C/Fortran parts of the code that are computationally expensive, while keeping the rest in pure Python for convenience.

Doing what you propose will be, a) hard to maintain b) slow, as using Cython is more than about compiling the original Python code, you need to do quite a bit of work to get a significant performance gains, and doing that for all of your code is just a waste of time.

Bottom line, either use Cython only for parts of your code where this will be beneficial and build your project with pyinstaller etc, or switch to C++ or any other compiled language, if that is what you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM