未加星标

Google boosts Python by turning it into Go

字体大小 | |
[开发(python) 所属分类 开发(python) | 发布者 店小二05 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

Google boosts Python by turning it into Go

python may be getting a performance boost from a competitor: theGoogle Go language.

Grumpy, an experimental project from Google, transpiles Python code into Go, allowing Python programs to be compiled and run as static binaries using the Go toolchain. It's as creative an application for Go as it is a transformation of Python's use cases.

In a blog post announcing the open source release, Google stated the project stemmed from its efforts to speed up the Python-powered front end for YouTube. But Google hit an obstacle that's familiar to folks who've deployed Python in production: It's hard to get CPython -- the default Python interpreter written in C -- to scale efficiently.

"We think Grumpy has the potential to scale more gracefully than CPython for many real world workloads," writes Google.

Lose a little, gain a lot

While Grumpy compiles Python code to a static binary via the Go toolchain, that's not the chief reason for its touted speed. After all, other projects to compile Python to binaries exist, but they don't necessarily provide a speed boost because of Python's dynamic type system. Cython, for instance, provides major speedups only when the developer supplies static C-style type information.

According to Google, Grumpy speeds Python code by doing away with some CPython legacy baggage. The largest is a deliberate lack of support for C extension modules, which allows C/C++ code to be made available to Python. A huge number of libraries use C extension modules, including many supplied with Python's standard library (such as ctypes , for interfacing with C code from Python).

Because it doesn't support C extensions, Grumpy doesn't have CPython's Global Interpreter Lock, which is commonly cited as a roadblock to running Python concurrent workloads smoothly. Grumpy also uses Go's garbage collection mechanisms to manage memory under the hood, instead of CPython's.

Grumpy creates close interoperation between Python and Go by allowing Go packages to be imported and used with the same syntax as Go modules. It's reminiscent of the pythonnet project, which allows Python to interoperate with .Net assemblies.

Missing pieces

Go and its toolchain have already been used by some third parties to develop new languages.TheHaveproject employed Go as a transpilation target, and theOdenproject experimented with Go's toolchain to create a functional language in the vein of Haskell or Lisp. Work on Oden ceased at the end of last year, although Have remains under active development.

With Grumpy, Go's toolchain helps re-implement an existing language with a broad, existing user base. It's possible Google will see good internal results with it since it's part of a custom-built use case. But success with the broader Python community depends on lifting or working around many existing roadblocks.

For one, Grumpy only supports Python's older Python 2.x syntax, though Python 2 itself is scheduled for decommission in 2020. Much of the standard library hasn't been ported, and functions like exec or eval , which execute Python code on the fly, are not yet implemented.

The biggest missing piece isn't support for C extensions themselves, but the libraries that depend on them.Without C extensions, only the most vanilla Python scripts can be compiled and run under the current interation of Grumpy. In time, it might be possible to devise replacements for them written in Go rather than C, but that's not a trivial project. Many Python libraries with big followings, like NumPy, would be completely unusable -- and such libraries are a big part of Python's draw.

本文开发(python)相关术语:python基础教程 python多线程 web开发工程师 软件开发工程师 软件开发流程

主题: Python.NetC++Lisp
分页:12
转载请注明
本文标题:Google boosts Python by turning it into Go
本站链接:http://www.codesec.net/view/520523.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(python) | 评论(0) | 阅读(86)