explaingit

google/grumpy

10,505GoAudience · developerComplexity · 4/5Setup · hard

TLDR

A Google tool that compiles Python 2.7 code into Go and produces a standalone native binary, bypassing the Python runtime entirely for faster performance and Go-style concurrency.

Mindmap

mindmap
  root((repo))
    What it Does
      Compiles Python to Go
      Produces native binary
      Skips Python runtime
    Components
      grumpc compiler
      Go runtime library
      Standard lib ports
    Limitations
      No eval or exec
      No C extensions
      Python 2.7 only
    Use Cases
      Speed up Python services
      Native binary output
      Compiler research
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Compile an existing Python 2.7 service into a native Go binary to get better CPU performance without rewriting the code from scratch.

USE CASE 2

Use grumprun to pipe a small Python snippet through the compiler and see the Go output to understand how the translation works.

USE CASE 3

Study the Grumpy runtime library to understand how Python object semantics are mapped onto Go types.

USE CASE 4

Use the project as a reference for how to build a language compiler in Go that targets another language's runtime model.

Tech stack

GoPython

Getting it running

Difficulty · hard Time to first run · 1day+

Python 2.7 only, no C extension support, and the project is no longer actively maintained, treat as a research reference rather than a production tool.

In plain English

Grumpy is a tool from Google that takes Python code and converts it into Go code, which is then compiled into a native program. In most Python environments, your code runs inside a virtual machine that interprets it step by step. Grumpy skips that entirely: your Python gets translated into Go, and the result is a standalone native binary. The project targets Python 2.7 compatibility. The practical use case is performance-sensitive services that are already written in Python but need the speed and concurrency characteristics of Go. Rather than rewriting code from scratch, a team could run it through Grumpy and get a compiled Go program. Google used this internally for some infrastructure work. There are real limits to what Grumpy can handle. Dynamic features like eval and exec are not supported, because the translation step happens at build time and those features require a live interpreter to work. C extension modules (common add-ons in the Python ecosystem) are also not supported, since Grumpy uses a different internal structure than the standard Python runtime. Some parts of Python's standard library are missing or incomplete. The project has three main pieces: a compiler called grumpc that reads Python and writes Go, a runtime library written in Go that handles Python-style objects and operations during execution, and a set of standard library modules ported to work in this environment. A helper script called grumprun lets you pipe Python code directly in and get results out, which makes quick testing straightforward. The repository is written in Go and Python, and the source is available on GitHub. It has not been actively maintained in recent years, so it is best treated as a reference project rather than a production-ready tool.

Copy-paste prompts

Prompt 1
I have a Python 2.7 script I want to compile to a native binary using Grumpy. Walk me through installing grumpc and the Go runtime, then show me the commands to compile and run the script.
Prompt 2
Using grumprun, pipe this Python 2.7 snippet through Grumpy and show me the compiled Go output: `print('hello world')`
Prompt 3
My Python 2.7 service uses a C extension module. Will Grumpy be able to compile it? Explain what Grumpy does and does not support based on its README.
Prompt 4
Explain how Grumpy handles Python's dynamic features like `eval` and `exec` at compile time and why they are not supported.
Prompt 5
I want to understand how Grumpy maps Python objects to Go types in its runtime library. Walk me through the key concepts from the repo.
Open on GitHub → Explain another repo

← google on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.