The company developed Grumpy because of the difficulty of making multiple millions of concurrent workloads perform well on CPython, which handles the YouTube front-end.
Other Python runtimes weren't able to solve the concurrency issue without introducing unsatisfactory trade-offs, according to Dylan Trotter, a staff software engineer within YouTube Engineering at Google.
"So we asked ourselves a crazy question: What if we were to implement an alternative runtime optimised for real-time serving?" wrote Trotter in a blog posting revealing the tool and the decision to open source it.
"Once we started going down the rabbit hole, Go seemed like an obvious choice of platform since its operational characteristics align well with our use case."
YouTube needed first-class language interoperability and Go's powerful runtime type reflection system made this straightforward, he added.
"Grumpy is an experimental Python runtime for Go. It translates Python code into Go programs, and those ‘transpiled' programs run seamlessly within the Go runtime. We needed to support a large existing Python codebase, so it was important to have a high degree of compatibility with CPython (quirks and all). The goal is for Grumpy to be a drop-in replacement runtime for any pure-Python project," wrote Trotter.
However, two compromises had to be made: first, Grumpy forgoes support for C-language extension modules. This means that Grumpy can't leverage existing Python C extensions, but the benefit in terms of performance justifies that decision, claims Trotter.
"Second, Grumpy is not an interpreter. Grumpy programs are compiled and linked just like any other Go program. The downside is less development and deployment flexibility, but it offers several advantages," wrote Trotter.
These include opportunities for optimisation at compile time via static program analysis. "But the biggest advantage is that interoperability with Go code becomes very powerful and straightforward: Grumpy programs can import Go packages just like Python modules!" he adds.
However, Trotter warns that although Grumpy has been freshly released to open source, it remains alpha-grade software. "Most of the language constructs and many core built-in types work like you'd expect [but] there are still holes to fill — many built-in types are missing methods and attributes, built-in functions are absent and the standard library is virtually empty."
AlphaBay users had flocked to Hansa after it was closed down - not realising it had already been taken over by Dutch police
Microsoft closes in on $100bn annual revenues with sales weighing-in at $23.3bn
Moves to take down cyber-squatted domains reveals Fancy Bear hacking network, claims Microsoft
Intel claims 'world first' in artificial intelligence that can be plugged-in almost anywhere