[Python-Dev] xmlrpclib speed boost

Fred L. Drake, Jr. fdrake@acm.org
Mon, 1 Oct 2001 15:20:37 -0400


Guido van Rossum writes:
 > It's kind of sad that the escape() function, which is only a few
 > lines, comes from the cgi module which is thousands of lines that are
 > not normally used except by actual CGI scripts.

  Yep.
  In this case, it probably makes more sense to call the escape()
function from the xml.sax.saxutils module, though.  The cgi version is
for HTML and the xml.sax.saxutils version is for XML (big surprise).
With only one argument, though, there's no difference.
  If we really want to deal with the startup time problem (regardless
of which module we get the escape function from), we could do this:


def _escape(s):
    global _escape
    import xml.sax.saxutils
    _escape = xml.sax.saxutils.escape
    return _escape(s)


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation