Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I pre-compile a python script?

Tags:

python

I have a python script. Lets say http://domain.com/hello.py, which only prints "Hello, World!".

Is it possible to precompile this Python file?

I get around 300 requests per second and the overhead of compiling is way to high. In Java the server can handle this easily but for calculations Python works much easier.

like image 966
user3605780 Avatar asked Dec 24 '22 19:12

user3605780


1 Answers

the problem is not that you need to "precompile" python, the problem is that you are trying to execute python scripts using normal cgi script stuff...

the real answer is to use a better web backend than simple cgi to run your python

I would suggest the following in order of appearance

  1. nginx + gnunicorn
  2. apache2 + mod-wsgi
  3. something else
  4. anything else
  ...
n-1. fcgi
  n. cgi

I know this isnt really an answer and is entirely opinion based

like image 162
Joran Beasley Avatar answered Jan 08 '23 23:01

Joran Beasley