#!/usr/local/bin/python2 import xml.etree.ElementTree as et r = et.XML('ahhnfh') for i in xrange(500000): ''.join(c.tail or '' for c in r) print ''.join(c.tail or '' for c in r)