bfi
A fast optimizing Brainfuck interpreter in pure python
What it is and what it does
bfi is a pure-Python interpreter for Brainfuck, an esoteric programming language. It works by first compiling Brainfuck source code into an intermediate bytecode form that collapses common instruction sequences—such as runs of cell pointer movements—into single optimized operations. This compilation step allows bfi to execute Brainfuck programs significantly faster than naive interpreters that process each source character individually.
The package supports both Python 2 and Python 3, has no external runtime dependencies, and can be used either from the command line (via the `bfi` command) or imported as a module in your own code. It includes configurable tape size (default 30,000 cells) and wrapping overflow/underflow behavior. The package ships with example Brainfuck programs demonstrating various algorithms and games.
Use it for:
- Run Brainfuck programs from the command line without installing a separate interpreter or compiler
- Execute Brainfuck code programmatically from Python, capturing output or providing custom input
- Learn or teach esoteric language design and compilation techniques through a working pure-Python example
- Benchmark or compare Brainfuck interpreter performance across implementations
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pure-Python interpreter for Brainfuck that compiles source code into an optimized intermediate form for faster execution than direct interpretation.
Yes, if you need to run or study Brainfuck code. The package is lightweight, dependency-free, and genuinely faster than comparable pure-Python alternatives. However, maintenance is aging (last release 279 days ago), so treat it as stable but not actively developed. Not relevant for production systems or non-Brainfuck use cases.
Install
bfi on PyPI
pip
pip install bfiuv
uv add bfipoetry
poetry add bfiInstalling bfi
Before you install
Low friction install with no runtime dependencies. Maintenance is aging—last release was 279 days ago, though the repository remains active and the package has been stable since its first release in 2017.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions, making it suitable for both personal and commercial projects.
Quickstart
pip install bfi
import bfi
with open('hello_world.b', 'r') as fh:
code = fh.read()
output = bfi.interpret(code, stdin='', buffer_stdout=True)
print(output)
Verify before relying
- Whether the package is actively maintained beyond bug fixes, or if development has effectively stalled
- Performance characteristics on modern Python versions beyond the CPython 2.7.14 benchmark mentioned in the documentation
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 279 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 338,545/month — #7,430 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: bfi-1.1.1-py2-none-any.whl; bfi-1.1.1-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
formulasParses and compiles Excel formulas and…
copyleft · top 5,000 on PyPI
ailmentAILment provides the intermediate language (IL)…
permissive · top 15,000 on PyPI
pyvexPyVEX provides Python bindings to libVEX,…
copyleft · top 15,000 on PyPI
pyqirPyQIR generates, parses, and analyzes QIR…
permissive · top 15,000 on PyPI
dukpyDukPy is a JavaScript interpreter for Python…
permissive · top 15,000 on PyPI
numbaNumba is a just-in-time compiler that…
permissive · top 1,000 on PyPI
lambdalibLambdalib provides technology-agnostic hardware…
permissive · top 15,000 on PyPI
Js2PyJs2Py translates and executes JavaScript code…
permissive · top 5,000 on PyPI
WhooshWhoosh is a pure-Python full-text search and…
permissive · top 5,000 on PyPI
tensorflow-intelIntel-optimized TensorFlow for Windows that…
permissive · top 15,000 on PyPI