classification
Title: Add support to compile to native binary like as with golang
Type: enhancement Stage: resolved
Components: Cross-Build Versions: Python 3.9
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Alex.Willmer, WHK Yan, terry.reedy
Priority: normal Keywords:

Created on 2019-09-25 19:05 by WHK Yan, last changed 2019-09-27 20:25 by terry.reedy. This issue is now closed.

Messages (2)
msg353224 - (view) Author: WHK Yan (WHK Yan) Date: 2019-09-25 19:05
It would be very useful to be able to compile at a low level a complete Python functional script and generate a native binary for each type of operating system and architecture just like golang does.

For example:

Run script: $ go run script.go
Compile script: $ GOOS=linux GOARCH=amd64 go build -o test test.go

The generated binary does not require goland installed to be executed and does not require complex dependencies. This allows me to distribute applications in binary are an excellent performance without requiring the installation of the entire interpreter.

Golang's problem is that it is not an intuitive language and the learning curve is very long, they had a very good idea but they carried it out in a horrible way.

On the other hand, python is very flexible and very intuitive, the learning curve is very short, I learned python in less than a week and I have been creating python applications for several years, instead I have been trying to learn golang for months and it is excessively strange.

Why not combine the best of both worlds? Unite non-dependence and cross-platform distribution without relying on the interpreter and the most versatile and intuitive language?

For example:

Run script: $ python script.py
Compile pyc $ python -m compileall
Compile native: $ python -m ncompileall -k linux -a amd_64

When compileall generate the pyc files and ncompileall generate a native binaries without complex dependencies or python dependencies.

This would be a great advantage in equipment that does not require additional installation of components.

For example, on servers of some companies they do not allow you to install something that can affect the entire environment or ecosystem, in addition, in many cases the scripts require a specific version of python and cause problems when different versions are required to other applications, the complete compilation at low level would allow to resolve this conflict.

There are currently few projects that allow you to translate a python script to binary but most do not have support or do not have a good performance, if python already brought it integrated it would increase its use even more since it would not depend on the interpreter to be able to distribute a complete application that already include all its modules and others.
msg353406 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-09-27 20:25
The PSF and the core developer group do not have the resources to do this.  Pie in the sky proposals like this should be floated on python-list or perhaps python-ideas, where you can get more answers as to 'Why not ...?" or perhaps 'How to ...?".  (Several millions dollars?)
History
Date User Action Args
2019-09-27 20:25:47terry.reedysettitle: Feature request: Add support to compile to native binary like as golang -> Add support to compile to native binary like as with golang
2019-09-27 20:25:11terry.reedysetstatus: open -> closed

versions: - Python 3.6, Python 3.7, Python 3.8
nosy: + terry.reedy

messages: + msg353406
resolution: rejected
stage: resolved
2019-09-25 19:05:18WHK Yancreate