Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (16.4k points)
I'm totally new to the Python programming language. I was contemplating whether it is conceivable to compile a program to write in Python.

Is it conceivable to change over Python scripts to some lower-level programming lang's which at that point can be compiled to binary code?

A developer who is thinking about coding in Python should keep the chance open to having the option to go for binary distribution later.

1 Answer

0 votes
by (26.4k points)

I figure Compiling Python Code would be a decent place to begin:

Python source code is automatically compiled into Python byte code by the CPython interpreter. Compiled code is usually stored in PYC (or PYO) files, and is regenerated when the source is updated, or when otherwise necessary.

To distribute a program to people who already have Python installed, you can ship either the PY files or the PYC files. In recent versions, you can also create a ZIP archive containing PY or PYC files, and use a small “bootstrap script” to add that ZIP archive to the path.

To “compile” a Python program into an executable, use a bundling tool, such as Gordon McMillan’s installer (alternative download) (cross-platform), Thomas Heller’s py2exe (Windows), Anthony Tuininga’s cx_Freeze (cross-platform), or Bob Ippolito’s py2app (Mac). These tools puts your modules and data files in some kind of archive file, and creates an executable that automatically sets things up so that modules are imported from that archive. Some tools can embed the archive in the executable itself.

Looking for a good python tutorial course? Join the python certification course and get certified.

For more details, do check out the below video tutorial...

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...