Electricmonk

Ferry Boender

Programmer, DevOpper, Open Source enthusiast.

Blog

pyBrainfuck

Saturday, March 22nd, 2008

For fun, I wrote a brainfuck interpreter in Python. Brainfuck is an esoteric (joke) programming language which is Turing-complete (given enough memory) with only 8 op-codes (instructions). It was designed to allow for the smallest possible compiler.

There are already some other Brainfuck implementations in Python, but they are either obfuscated or extremely slow. pyBrainfuck is optimized for speed by pre-caching loops and removing non-brainfuck opcodes.

PyBrainfuck can be used both as a stand-alone Brainfuck interpreter or as a python library. It can read from standard input or from a string (in library mode) and write to standard out or to a string buffer (in library mode).

pyBrainfuck is released under the MIT license. You can directly view the code for the interpreter at BitBucket.

The text of all posts on this blog, unless specificly mentioned otherwise, are licensed under this license.