#!/usr/local/bin/python2 s = '{dfsghg}dasfgh' for i in xrange(1000000): _, _, t = s.rpartition('}') print t