#!/usr/local/bin/python2 import xml.etree.ElementTree as et r = et.XML('<r><a></a>ahhnfh<b></b></r>') for i in xrange(10000): ''.join(c.tail for c in r if c.tail is not None)