Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fbacaf7

Browse files
author
Skip Montanaro
committed
approximately double dump performance by moving import of cgi.escape back to
top level.
1 parent 419abda commit fbacaf7

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

Lib/xmlrpclib.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136

137137
import re, string, time, operator
138138
from types import *
139+
from cgi import escape as _escape
139140

140141
try:
141142
unicode
@@ -472,15 +473,13 @@ def dump_double(self, value):
472473
dispatch[FloatType] = dump_double
473474

474475
def dump_string(self, value):
475-
from cgi import escape
476-
self.write("<value><string>%s</string></value>\n" % escape(value))
476+
self.write("<value><string>%s</string></value>\n" % _escape(value))
477477
dispatch[StringType] = dump_string
478478

479479
if unicode:
480480
def dump_unicode(self, value):
481481
value = value.encode(self.encoding)
482-
from cgi import escape
483-
self.write("<value><string>%s</string></value>\n" % escape(value))
482+
self.write("<value><string>%s</string></value>\n" % _escape(value))
484483
dispatch[UnicodeType] = dump_unicode
485484

486485
def container(self, value):
@@ -513,8 +512,7 @@ def dump_struct(self, value):
513512
write("<member>\n")
514513
if type(k) is not StringType:
515514
raise TypeError, "dictionary key must be string"
516-
from cgi import escape
517-
write("<name>%s</name>\n" % escape(k))
515+
write("<name>%s</name>\n" % _escape(k))
518516
self.__dump(v)
519517
write("</member>\n")
520518
write("</struct></value>\n")

0 commit comments

Comments
 (0)