[pypy-dev] Running Python in reverse

Alexander Schliep schliep at molgen.mpg.de
Fri Jan 7 12:04:10 CET 2005

Hi everyone,

Christian Tismer encouraged me to post the following directly to the
pypy mailing list.

My main Python project is Gato, a software for visualizing (or
animating) graph algorithms; see
http://gato.sourceforge.net/wiki/pmwiki.php/Main/Screenshots.  The
main ingredients of Gato are a debugger subclass, some GUI elements
and code for drawing graphs.

The goal is to have an interactive, dynamic version of the classical
comp.sci. text book, where, typically, some graph algorithm is given
as pseudo code and you see (at best) a before, during, and after
snapshot picture of its working on some graph.

Python is a perfectly fine replacement for pseudo code and the
execution and directly coupled visualization, which you can control
just like a debugger, convey much more than static pictures. Winfried
Hochstaettler, some university colleagues, and myself have used this
for teaching discrete math, combinatorial optimization and
comp.sci.classes with quite favorable comments from everyone involved.

The number one request was always the ability to track back. I started
to implement an instant replay of the last visualization effect
(change of color, blink etc.) and started to think about a proper way
of supporting the ability to step back in time. This essentially boils
down to implementing one of the classical design patterns for
supporting unlimited undo (and redo), treating the visualization
effects as commands.

This decouples the state (values of all variables used) of the
algorithm from the state of the visualization, hence running the
algorithm after a couple of Undos is not possible (One could fake that
by Redoing everything and then continuing execution). Supporting an
update of all variables gets kind of messy in standard Python.

A cleaner approach would be to have a Python interpreter which can run
backwards. Christian thinks it would be feasible in PyPy.

This actually would be extremely nice for a number of applications
- teaching Python

- teaching algorithms with Python

- debugging in general

I am somewhat embarrassed to ask for a feature without much to offer.
But realistically, I cannot promise more than to be a tester and happy


PS: Gato is LGPL.  The algorithms we have are copyright Springer, as
we have a textbook & software package coming out this year.

PPS: There is a C-syntax-based tool which can run backwards:

schliep at molgen.mpg.de	                  http://algorithmics.molgen.mpg.de

More information about the Pypy-dev mailing list