Note that this is essentially a data-compression problem, so the most accurate solution is probably to use an instrumeted PAQ compressor in a certain smart way, but you have to work a lot to implement this solution, and maybe this problem doesn't deserve all this work.
Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list