Software

Devops

Google's Grumpy code makes Python Go

With a transcompiling tool, YouTube aims to overcome Python's limitations


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. ®

Send us news
55 Comments

Malware in Lisp? Now you're just being cruel

Miscreants warming to Delphi, Haskell, and the like to evade detection

Apps-from-prompts Firebase Studio is a great example – of why AI can't replace devs

Big G reckons this agentic IDE speeds up or simplifies coding. Developers who've used it aren't so sure

Feds drop bomb on Multiplan in legal war over healthcare 'price-fixing' algorithms

DoJ suggests it sure looks like collusion when several big players use the same cost-saving software

Open Source Initiative defends disallowing board candidate after timezone SNAFU

Here's another thing AI can do: Cause conflict around whether it's compatible with the very idea of open source

GitLab and its execs sued again and again over 'misleading' AI hype, price hikes

Bosses bragged about Duo Chat bot, buyers weren’t buying it – claim

Time to make C the COBOL of this century

Lions juggling chainsaws are fun to watch, but you wouldn't want them trimming your trees

How a good business deal made us underestimate BASIC

A somewhat savvy hardware move may have hurt street cred of an important language

AI can improve on code it writes, but you have to know how to ask

LLMs do more for developers who already know what they're doing

CAPTCHAs now run Doom – on nightmare mode

As if the bot defense measure wasn't obnoxious enough

Open source maintainers are drowning in junk bug reports written by AI

Python security developer-in-residence decries use of bots that 'cannot understand code'

GitHub's boast that Copilot produces high-quality code challenged

We're shocked – shocked – that Microsoft's study of its own tools might not be super-rigorous

Abstract, theoretical computing qualifications are turning teens off

BCS calls for digital literacy GCSE alongside Computer Science

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant