Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #71987

Re: Make Python Compilable, convert to Python source to Go

Newsgroups comp.lang.python
Date 2014-05-25 01:17 -0700
References <4300c94d-316b-46b8-9d51-856b60273334@googlegroups.com> <mailman.10279.1400993256.18130.python-list@python.org>
Message-ID <e2148a68-443b-43e8-9f68-6c36d13f08a5@googlegroups.com> (permalink)
Subject Re: Make Python Compilable, convert to Python source to Go
From bookaa bookaa <rorsoft@gmail.com>

Show all headers | View raw


On Sunday, May 25, 2014 12:47:27 PM UTC+8, Chris Angelico wrote:
> On Sun, May 25, 2014 at 1:06 PM, bookaa wrote:
> 
> > 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).
> >
> 
> Sounds like you're writing a Python implementation that uses a Go
> backend. As Pythons go, this is comparable to using Java, or Mono, or
> RPython, or C, or anything else. So there are two questions:
> 
> 1) How compatible is your Python-to-Golang converter with all the
> nuances of Python code? Does it work perfectly on any arbitrary Python
> script? And, what version of Python is it aimed at?

I try to support all Python syntax, any arbitray script. From the example
 attached,you can see I translate all import system libraries needed and 
produce up to 170000 lines of Go. Up to now, only support Python 2.7.6. 
Maybe I will work on Python 3 later.

> 2) What's performance like? Presumably significantly better than
> CPython, as that's what you're boasting here. Have you run a
> standardized benchmark? How do the numbers look?
 
I must admit that after automaticaly convert Python source to Go, compile 
to EXE, the running speed is just as before. For compatible reason, I must 
make it behave just as it before, support any Python feathers. Take a 
example, if we find a function call func1(2), I can not simply convert it 
to Go function call as func1_in_go(2), but something like this: current_module_scope.GetAttributeString("func1").CallObject(2)
because func1 maybe overwrited.

I think the significance of Python to Go, is it give us opportunity to 
make Python project run fast. We may edit the output Go source. or We 
may add some Python decorator to tell the converter its safe to convert 
it in simple form.
 

> If the answer is "It'll work on anything, but it's only faster if you
> restrict yourself to a specific subset of Python syntax", that's still
> useful. But we'd need to see figures that tell us when it's worth
> adding a separate dependency and another translation layer (after all,
> every layer adds its own bug potential).
> 
> ChrisA

thanks, LiuTaoTao

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Make Python Compilable, convert to Python source to Go bookaa bookaa <rorsoft@gmail.com> - 2014-05-24 20:06 -0700
  Re: Make Python Compilable, convert to Python source to Go Chris Angelico <rosuav@gmail.com> - 2014-05-25 14:47 +1000
    Re: Make Python Compilable, convert to Python source to Go bookaa bookaa <rorsoft@gmail.com> - 2014-05-25 01:17 -0700
      Re: Make Python Compilable, convert to Python source to Go Chris Angelico <rosuav@gmail.com> - 2014-05-25 18:52 +1000
      Re: Make Python Compilable, convert to Python source to Go Stefan Behnel <stefan_ml@behnel.de> - 2014-05-25 11:30 +0200
      Re: Make Python Compilable, convert to Python source to Go Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-25 11:24 +0100
        Re: Make Python Compilable, convert to Python source to Go mm0fmf <none@mailinator.com> - 2014-05-25 12:02 +0100
          Re: Make Python Compilable, convert to Python source to Go Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-25 12:40 +0100
      Re: Make Python Compilable, convert to Python source to Go Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-05-25 23:31 -0700
      Re: Make Python Compilable, convert to Python source to Go Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-26 12:17 +0100
        Re: Make Python Compilable, convert to Python source to Go Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-27 01:24 +0000
  Re: Make Python Compilable, convert to Python source to Go wxjmfauth@gmail.com - 2014-05-25 00:57 -0700
  Re: Make Python Compilable, convert to Python source to Go Ben Finney <ben@benfinney.id.au> - 2014-05-26 13:20 +1000
  Re: Make Python Compilable, convert to Python source to Go Stefan Behnel <stefan_ml@behnel.de> - 2014-05-26 09:18 +0200

csiph-web