approximately double dump performance by moving import of cgi.escape back to
top level.
This commit is contained in:
parent
419abdaff2
commit
fbacaf7298
|
@ -136,6 +136,7 @@ Exported functions:
|
||||||
|
|
||||||
import re, string, time, operator
|
import re, string, time, operator
|
||||||
from types import *
|
from types import *
|
||||||
|
from cgi import escape as _escape
|
||||||
|
|
||||||
try:
|
try:
|
||||||
unicode
|
unicode
|
||||||
|
@ -472,15 +473,13 @@ class Marshaller:
|
||||||
dispatch[FloatType] = dump_double
|
dispatch[FloatType] = dump_double
|
||||||
|
|
||||||
def dump_string(self, value):
|
def dump_string(self, value):
|
||||||
from cgi import escape
|
self.write("<value><string>%s</string></value>\n" % _escape(value))
|
||||||
self.write("<value><string>%s</string></value>\n" % escape(value))
|
|
||||||
dispatch[StringType] = dump_string
|
dispatch[StringType] = dump_string
|
||||||
|
|
||||||
if unicode:
|
if unicode:
|
||||||
def dump_unicode(self, value):
|
def dump_unicode(self, value):
|
||||||
value = value.encode(self.encoding)
|
value = value.encode(self.encoding)
|
||||||
from cgi import escape
|
self.write("<value><string>%s</string></value>\n" % _escape(value))
|
||||||
self.write("<value><string>%s</string></value>\n" % escape(value))
|
|
||||||
dispatch[UnicodeType] = dump_unicode
|
dispatch[UnicodeType] = dump_unicode
|
||||||
|
|
||||||
def container(self, value):
|
def container(self, value):
|
||||||
|
@ -513,8 +512,7 @@ class Marshaller:
|
||||||
write("<member>\n")
|
write("<member>\n")
|
||||||
if type(k) is not StringType:
|
if type(k) is not StringType:
|
||||||
raise TypeError, "dictionary key must be string"
|
raise TypeError, "dictionary key must be string"
|
||||||
from cgi import escape
|
write("<name>%s</name>\n" % _escape(k))
|
||||||
write("<name>%s</name>\n" % escape(k))
|
|
||||||
self.__dump(v)
|
self.__dump(v)
|
||||||
write("</member>\n")
|
write("</member>\n")
|
||||||
write("</struct></value>\n")
|
write("</struct></value>\n")
|
||||||
|
|
Loading…
Reference in New Issue