Tested both my codes against a random string of length = 10000. ===========================================
from random import choice s = '' for i in xrange(10000): s += choice(('a','b','c','d','e','f')) =========================================== C++: ~0.28s Python: ~0.48s PS I suspect that building of Suffix Tree would be a big exec.time-consuming overhead -- http://mail.python.org/mailman/listinfo/python-list