Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cython for a Django app: would it work?

Would compiling with cython work with a python 3.4 Django app, or could it be made to work without a huge amount of effort?

This answer - https://stackoverflow.com/a/7347168/805141 - to a question about protecting python code prompted me to ask this question.

A similar question has been asked previously but with regards to improving performance: Using Cython with Django. Does it make sense?

like image 333
Daniel Avatar asked Sep 15 '15 04:09

Daniel


People also ask

Can we use Cython for Django?

Yes, we have done it.

Can Cython compile all Python code?

You can't, Cython is not made to compile Python nor turn it into an executable.


1 Answers

Yes, we have done it. But it point of consistent pain.

We make a commercial product which is installed on the customer premise to manage their Genesys power contact center. The core of the application is written in Django and we wanted to protect (limit) the code from inspection.

There is a speed improvement from running in native python but it is not a considerable difference. The improvement depends on the type of task, sometimes up to 30% sometimes minimal.

We run into issues from time to time where something works in Python but then it does not in Cython. I would not recommend this path unless you have a really good motivation.

Currently version runs on Python 3.5 with Django 1.11

like image 111
oden Avatar answered Sep 20 '22 09:09

oden