The generated code is slow though, because range() is slow. I can either manually change all ranges to the "from 1 <= i <= dim -1" idiom, but that's annoying. I prefer Cython to do it automatically (for example by providing a switch "--convertrange" or something, it doesn't have to be default).
Here is a simple script which does that:
It opens a file, changes all range(..) to from ..., and prints the result to stdout. You need pyparsing to run it: