How to Create .Pyc File to Run on Web
Python is a popular open source scripting language. Unfortunately, as an interpreted, read-on-the-fly scripting language, it comes with the caveat of being slower than a compiled or statically converted to byte-code language. In high-traffic online applications, speed is critical. Conveniently, Python allows programmers the productivity of a high-level language, while allowing programmers to "compile" python code for greater speed. This makes Python ideal for the web environment, where both programmers and programs need to be fast.
Instructions
-
-
1
Install Apache. If you're using Windows, the easiest way to do this is by using the WAMP or XAMPP packages. These packages install Apache through a point and click installer. If you're using Linux, Apache comes installed. Install MAMP if you're using a Mac.
-
2
Download mod_python from modpython.org. Install Python using mod_python. Installation instructions differ depending on the distribution of Apache you chose in the previous step. Consult your distribution's documentation for specific details. This entails copying the mod_python file to your Apache directory and modifying configuration files specific to the version of Apache being used.
-
-
3
Open your text editor. Type "print 'hello world'" and save your file. Copy this file to the home directory of your Apache installation. Usually this is a folder called "htdocs." Run the file by double-clicking on it. Python should have created a .pyc file in that directory. Whenever the original python file is run, the .pyc file is run instead.
-
1
References
- Photo Credit cluster disaster concept image by .shock from Fotolia.com