5 ms·
It's great that they are splitting the RPython docs out from the PyPy ones. One thing I found lacking while writing a simple BrainFuck interpreter in RPython i
by orf 12y ago
It's great that they are splitting the RPython docs out from the PyPy ones.
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.
- alexanderblom 12y agoDo you have any resources for this? I was thinking of looking into that but don't know where to start.
- orf 12y agoBrainFuck is a great place to start because it's pretty simple. I started with this post on the PyPy blog: http://morepypy.blogspot.co.uk/2011/04/tutorial-writing-interpreter-with-pypy.html http://morepypy.blogspot.co.uk/2011/04/tutorial-writing-inte... This repository helped as well: https://github.com/thoughtpolice/bf-pypy 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.html http://calmerthanyouare.org/2015/01/07/optimizing-brainfuck....
- sanxiyn 12y agoPyPy project maintains an example interpreter to learn from. https://bitbucket.org/pypy/example-interpreter https://bitbucket.org/pypy/example-interpreter
- thomasjames 12y agoThey have been trying to improve the exact specification of RPython since David Beazley sorta called the project out on the fact that, for a time early in the development of PyPy, RPython was basically whatever subset of Python survived the PyPy build process. The 2012 PyCon keynote gives and awesome explanation of the project internals and its promise: https://www.youtube.com/watch?v=l_HBRhcgeuQ https://www.youtube.com/watch?v=l_HBRhcgeuQ