def _quote_str(o):
    """Escape a str/unicode object. Note that compiled code never uses ' for attributes and >
    doesn't needed to be escaped to form valid HTML. These replace calls are a big cost,
    so saving 40% of them is a win.
    """
    return o.replace(u'&', u'&amp;').replace(u'<', u'&lt;').replace(u"'",
        u'&#39;')
