Python to Golang, sample 2


bookaa bookaa

This is the 2nd test sample for my 'Python to Go' project

refer to

download url:

This time I choose a 75 Python lines of Tetris game. It use PyGame library.
With my 'Python to Go', I convert it to Go source, compile, and it run.

This time I compile it on platform Win8 64bit.

Please open a Windows prompt window, go to directory BIN, and run the RUNME.BAT

Some Questions:

Q: Do you try to support all Python programs, or only some ?

A: I try to support all Python2 syntax(not Python3 yet). Especially I can translate
all Python standard libraries include. And I support programs which use 3rd part PYD

Q: After translate to Go, Does it realy run faster ?

A: Yes, it is! I made some effort to try to ditermine variable datatype for int,
float, string etc. And compute them with Go instead of PyObject. Even for those can
not determined data type condition, I also try to compute it in Go level with Go's
'reflect' tech.

Q: Again, significance of 'Python to Go'

A: Take this sample game for example. With Python it only need 75 lines. Can you try
it with Go ? You can not find the PyGame library, so maybe its impossible to do it in
Go. From impossible to possible, does it enough ?

Python's library is the most plentiful among all computer languages. This show how we
love Python. But it can not compile to binary, this limit its usage. Now with my Python
to Go, you can benefit hundreds of Python libraries in GoLang. I am sure this will make
the long-lived Python more powerful, and new-borned Go more powerful!

In my opinion. A good programming language should be 2 level. It should be unlimited
dynamic like Python during the developing period. We can express our idea freely, without
any limitation. After the program work normally, automatically or half-automatically or
manully, we can add some decorate code to limit some dynamic features we do not use. This
make it run faster, and easy to compile. Up to now, I do not find any this kind of
programming language. Many new language still choose hard between dynamic and run speed.

We can understand 'Python to Go' as the 2nd explanation of Python. Convert your Python
source to Go source and compile, it works in a different way.

Developing with Python, compile and run with Golang, anyone interest?

LiuTaoTao (e-mail address removed)


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question