Python Accelerator

I plan to use Python to develop a web application. Does anyone have an idea about any accelerator for python? (something like eAccelerator or apc for php) if not, is there any way to cache python precompiled bytecode? Any idea on comparing performance between python and php (assuming db / network delays are the same)

Thanks in advance.

+3
source share
4 answers

Others mentioned Python byte code files, but that pretty much doesn't matter. This is because hosting mechanisms for Python, with the exception of CGI, support the Python web application in memory between requests. This is different from PHP, which effectively drops the application between requests. Thus, Python does not need an accelerator, because the way the Python web hosting mechanisms work allows you to avoid the problems that PHP faces.

+3
source

There is a trick.

He is called mod_wsgi.

The essence of this is how it works.

  • For β€œstatic” content (.css, .js, images, etc.) put them in a directory to be served by Apache, without your Python program, knowing that they were submitted.

  • "" ( HTML) mod_wsgi "" , Apache.

, PHP, . Apache - , .

, HTML-, Apache Python, , . . Python. , .

+8

" script" (, python __name__ __main__), " - python": import foo, foo.py ( ) foo.pyc, , - " " Python foo.pyc , import foo - , import foo, , - (sys.module ). Python: , def - script esp, exec eval /! -).

PHP vs Python, , Python , , (idealy 2.7, 2.6), " Python". , cython ( Python, C, ), , .

+5

The compiled python bytecode is automatically cached in .pyc files in every environment I've seen. I need to do something else as far as I know.

If you want to generate these files directly, you can use: http://docs.python.org/library/py_compile.html

+2
source

Source: https://habr.com/ru/post/1762670/


All Articles