未加星标

Google's Grumpy code makes Python Go

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

Google on Wednesday introduced an open-source project called Grumpy to translate python code into Go programs.

The company's front-end server for YouTube and its YouTube API are mainly written in Python, and run on CPython 2.7, as opposed to other implementations (Jython, PyPy, or IronPython).

The issue for Google is performance. Python in its various forms doesn't excel at concurrency running multiple, independent threads at the same time explains YouTube engineer Dylan Trotter in a blog post .

Grumpy is a source code transcompiler and runtime. It compiles Python source code into Go source code that gets compiled into native code rather than bytecode that requires a VM.

The compiled Go code makes calls to the Grumpy runtime, which is a Go library that functions similarly to the Python C API.

Trotter characterizes Grumpy as experimental, but that doesn't mean support for Python 3 is forthcoming as the project matures. In response to a request for Python 3 support, Trotter on GitHub said, "We have a large Python 2.7 codebase so that's what we've been focused on. I definitely would like to support Python 3. It's just a bunch of work." He suggested those interested in Python 3 support should fork the project.

One possible rationale for creating Grumpy may be the planned end-of-life date for Python 2.7 in 2020 . Rather than trying to update all its Python code from version 2.7 to 3 which has been slow to catch on Google appears to be planning to convert at least some of its Python code to Go over the next few years.

Google didn't immediately respond to a request for comment.

In a post to Hacker News, Trotter offered his thoughts on the matter. "The idea is to continue to write code in Python," he said. "The transcompiled code is not suitable for working with directly. That said, there is the possibility of rewriting bits and pieces in Go (eg, performance-critical stuff) and then call into it from Python. Sort of a hybrid approach."

Three years hence and beyond, that hybrid approach can be expected to include a lot more Go code, provided Google's developers become as proficient with Go as they are with Python.

Go, as Trotter suggests, has performance advantages over Python (though benchmarks can vary significantly, depending upon optimizations and alternative implementations). It also has brand advantages: Go was developed at Google and the company's willingness to eat its own dogfood, so to speak, could convince other organizations that Go is the way to go.

Google doesn't benefit directly from Go adoption, but broader usage will deepen the talent pool of Go developers, who could in time end up working at Google or improving Go libraries that Google uses. There's also the opportunity cost imposed on competitors the more time developers spend with Go, the less they have to spend with languages backed by Apple, Microsoft, Mozilla, Oracle, or others.

Sponsored: Customer Identity and Access Management

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

主题: PythonGitGitHubApple
分页:12
转载请注明
本文标题:Google's Grumpy code makes Python Go
本站链接:http://www.codesec.net/view/520157.html
分享请点击:


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