Python eBPF: BCC C-String Runtime vs Python-BPF AST Ahead of Time

Nizar Akbar Meilani
Python developers writes eBPF historically used BCC, which embeds C code as strings and compiles at runtime via Clang/LLVM. In 2024, Python-BPF emerged, translating pure Python AST directly into BPF bytecode via llvmlite.
I profiled both with time, strace, py-spy, and perf. The results are stark: BCC spends 93% in C compilation via Clang versus Python-BPF's 27% in pure Python AST translation. Yet Python-BPF's parser has real gaps—no ctx.args0 support, no atomic map operations.
This talk reveals the middle-level performance data and trade-offs, helping you choose the right Python eBPF toolchain for your deployment.
Description
This talk compares two Python eBPF approaches: BCC (established, embeds C strings, compiles at runtime) vs Python-BPF (2024, pure Python AST to BPF bytecode). I'll present benchmarking methodology using time, strace, py-spy, and perf, revealing where overhead occurs. The analysis covers startup latency, syscall footprint, CPU flame graphs, and call chain analysis. I'll also discuss Python-BPF's current gaps: missing subscript handlers, non-atomic map operations, and parser limitations.
References:
- Python-BPF repository: https://github.com/python-bpf/python-bpf
- BCC repository: https://github.com/iovisor/bcc
- Related research notes from knowledge-pipeline:
- PythonBPF Overview: https://github.com/nizarakbarm/knowledge-pipeline/blob/main/Atlas/Dots/Things/PythonBPF/PythonBPF.md
- PythonBPF Architecture: https://github.com/nizarakbarm/knowledge-pipeline/blob/main/Atlas/Dots/Things/PythonBPF/Architecture.md
- Python-BPF Compiler Limitations: https://github.com/nizarakbarm/knowledge-pipeline/blob/main/Atlas/Dots/Things/PythonBPF/Python-BPF%20Compiler%20Limitations.md
- Kernel Memory Access Comparison: https://github.com/nizarakbarm/knowledge-pipeline/blob/main/Atlas/Dots/Things/PythonBPF/Kernel%20Memory%20Access%20BCC%20vs%20Python-BPF%20vs%20libbpf%20CO-RE.md
- Python-BPF Register Access: https://github.com/nizarakbarm/knowledge-pipeline/blob/main/Atlas/Dots/Things/PythonBPF/Python-BPF%20Register%20Access%20in%20ctx%20and%20The%20Argument%20Mapping.md
- BCC vs Python-BPF Benchmark Plan: https://github.com/nizarakbarm/knowledge-pipeline/blob/main/Efforts/On/BCC%20vs%20Python-BPF%20Benchmark%20Plan.md
- BCC Overview: https://github.com/nizarakbarm/knowledge-pipeline/blob/main/Atlas/Dots/Things/BCC%20eBPF/BCC.md
- eBPF Overview: https://github.com/nizarakbarm/knowledge-pipeline/blob/main/Atlas/Dots/Things/eBPF/eBPF%20(extended%20Berkeley%20Packet%20Filter).md

Nizar Akbar Meilani is a systems engineer specializing in Linux infrastructure, DevOps, SRE, and Infrastructure as Code. His analytical approach—prioritizing data over assumptions—was shaped by CTF reverse engineering in college. He has spoken at PyCon APAC 2024 ("WordPress Vulnerability Detection"), PyCon HK 2025 ("IPList to BPFRule: Python DDoS Mitigation"), and PyCon ID 2025 ("Python meets bpfilter and safeline"). Currently expanding into eBPF observability tooling for Python developers through empirical benchmarking. **Previous Talks:** - PyCon APAC 2024 - PyCon Hong Kong 2025 - PyCon Indonesia 2025