by orf · 11y ago · 0 comments
One thing I found lacking while writing a simple BrainFuck interpreter in RPython is lack of documentation on the best practices with regards to speed. Should I use classes, namedtuples or even just tuples to pass data around? Using a list seemed to slow things down a lot in some places but not others etc.
Apart from that I highly recommend people give PyPy a go if you're going to be writing an interpreter.
This repository helped as well: https://github.com/thoughtpolice/bf-pypy
Getting a basic interpreter working wasn't hard, but I attempted to add a few of the optimizations listed here[1], which meant adding some form of AST and stuff to manipulate it. This is where I got a bit stuck with regards to performance as some of my optimizations meant the program should have been faster, but instead it slowed down.
1. http://calmerthanyouare.org/2015/01/07/optimizing-brainfuck....