From fbacaf7298fe9118d1c41b11de7449729ecc0bcd Mon Sep 17 00:00:00 2001 From: Skip Montanaro Date: Mon, 1 Oct 2001 17:50:29 +0000 Subject: [PATCH] approximately double dump performance by moving import of cgi.escape back to top level. --- Lib/xmlrpclib.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py index ea4f9323a9c..37c9429da41 100644 --- a/Lib/xmlrpclib.py +++ b/Lib/xmlrpclib.py @@ -136,6 +136,7 @@ import re, string, time, operator from types import * +from cgi import escape as _escape try: unicode @@ -472,15 +473,13 @@ def dump_double(self, value): dispatch[FloatType] = dump_double def dump_string(self, value): - from cgi import escape - self.write("%s\n" % escape(value)) + self.write("%s\n" % _escape(value)) dispatch[StringType] = dump_string if unicode: def dump_unicode(self, value): value = value.encode(self.encoding) - from cgi import escape - self.write("%s\n" % escape(value)) + self.write("%s\n" % _escape(value)) dispatch[UnicodeType] = dump_unicode def container(self, value): @@ -513,8 +512,7 @@ def dump_struct(self, value): write("\n") if type(k) is not StringType: raise TypeError, "dictionary key must be string" - from cgi import escape - write("%s\n" % escape(k)) + write("%s\n" % _escape(k)) self.__dump(v) write("\n") write("\n")