← Back to the playground

PythonBPF Playground

Write eBPF programs in Python and run them in a real Linux kernel from your browser.

What is PythonBPF?

PythonBPF compiles a subset of Python into eBPF bytecode through LLVM, without BCC. Its companion library, pylibbpf, loads and attaches the programs and gives you their maps from ordinary Python. The documentation covers the language.

How it works

When you press Run, you get your own Firecracker microVM with its own Linux kernel. Your program is compiled to LLVM IR (shown in the LLVM IR tab), checked by the kernel's BPF verifier, loaded and attached. Its output streams back to the Output tab. The Terminal tab is a root shell in the same VM, so try bpftool prog list while a program runs. Your last program is in /work/main.py.

Limits

Safety

Programs run as root, but only inside the microVM. Each VM runs under Firecracker's jailer, which provides a chroot, an unprivileged user, an empty network namespace, seccomp filters and cgroup CPU and memory limits. Its root filesystem is read-only. If your program crashes the guest kernel, the VM restarts and nothing else is affected.

Sharing

Share puts your code, compressed, into the link itself. The server does not store any code.

Source

The playground is open source: github.com/pythonbpf/pythonbpf-playground. Bug reports for the compiler go to Python-BPF.