Make Python Compilable

This tool can be called 'Python to GoLang', which translate Python source to 
Golang source. And then you can compile the Go files to executable binary. 
(btw: Go is a new C-like compilable language, open source).

Generally, people consider Python as a script language. It has high development 
efficiency, but run too slowly, interpret running, and can not compile. It 
depends to Python environment, can not employ alone.

For years, many people have do a lot of job try to improve running speed of 
Python, include Pypy, Cython. But all of these are not satisfied.

In my opinion, Python only define a development rule. You can easily express 
your logic idea with this rule. It doesnot confines that it must be run as 
script. Only that we only have this C Python interpretor(CPython). So we take 
it for granted that Python is a script language.

I think no matter how you program your work, it only represent some logics. 
There should be possible to convert from one computer language to another. 
Based on this, after some months of work, we have this utility.

I consider Python as the most efficient langrage. Many genius programmers love 
Python and Go. Now with this tool, we can make Python compilable, and run more 
quickly. Python will be perfectly! We do not need C and C++ anymore! Python is 
not as before!

Q1: Why do we need convert Python source to Go ? Why not coding with Go 
directly ?
First, Python is good at develop efficiency. And Go is too simply and do not 
have many really-need functions. I do not suggest you choose Go as your primary 
development langrage. Second, Python has a lot of 3rd part libraries. And Go 
been as a new language, if can inherit all libraries from Python, it will be 
more powerful.

This tool can work in 2 options:
op1: If you want your product run under Python environment, or debug, you can 
choose op1. With this option, I will only convert your Python source files to 
Go, and ignore 'import' of system libraries. Mostly one line of Python will 
produce 1.5 lines of Go source, basicly preserve function, function names, 
variable names, calling graphics. The output Go source is easy to understand, 
optimize.
op2: Convert all Python source to Go including system libraries. Generally this 
will product more than 150 thousand lines of Go source. After compile, your 
execute binary file can run without Python installation. You should include 
Python27.dll and some PYD file if need.  Now its possible to deply your Python 
product.

Q2: Why do you need python27.dll ? If you include this dll, why just run with 
one line of 'exec' ?
If you run with 'exec', it is run with Python interpretor. You can not improve 
running speed. And its not safe.
I will convert all function of Python to a correspond Go function. All variable 
becomes a Go variable. I will try to identify data type of each variable. If I 
find a var is integer, I will use int in Go. This make it possible to improve 
running speed. For variables I do not know data type, or list, tuple etc, I use 
PyObject. So there is no choice but call correspond operation functions from 
python27.dll.
And many 3rd part libraries of Python is PYD compiled from C. This PYD file is 
actually DLL which dependance to python27.dll.

With this tool, we can benefit all libraries of Python in Go. This makes Go 
more powful. For example, we still do not have good GUI libraries for Go, now 
we can try GUI libraries of Python and its possible to begin GUI development 
with Go now.

It takes me more than 7 month to do this job, with more than 30000 lines of 
source, mostly in Python with some Go and C. As you may think, I can convert 
myself to Go! During the convertion, I must deal with complex Python logics. I 
must carefully understand any Python acknownledge point and try to find 
solution in Go. Its very difficault! Especially for some concept of Python 
which missing in Go, like try/exception, yield, var scope, no use var, var 
declare.

This tool will public and open source later. Up for now, only support Python 
2.7.6, do not support Python3. I have tested it on Win32, Win64, and I am sure 
its easy to run on all OS support Python and Go. Python is open source in C, Go 
is also open source in G. There can run on almost all operation system. With my 
Python to Go, I believe Python+Go will become popular development trend.

You can download this to have a look how Python to Go work. This is a small 
tool for listen and dictation of learning Foreigin languages by me.
http://pan.baidu.com/s/1eQADiHc
including Python source, and converted Go sourced(more than 170000 lines), and 
compiled executable binary(win32).

I may help you:
1. convert your Python project to Go. Its quick and safe and easy to deploy.
2. optimize running speed of your Python project
3. Make a speech.
LiuTaoTao 9870...@qq.com
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to