Use a list to store feed data in JSONUnmarshaller
Creating a new string could be very expensive for large amount of data, especially because xmlrpclib read response and feed the parser with chunk of 1024. So it is better to store the feed data in a list and create the string only once when closing the parser. issue5237 review19951003
This commit is contained in:
1 parent
29b56e3929
commit
c81a4f93a0
1 file changed
+4
-3
+4
-3
@@ -125,13 +125,14 @@ class JSONParser(object):
|
||||
|
||||
|
||||
class JSONUnmarshaller(object):
|
||||
data = ''
|
||||
def __init__(self):
|
||||
self.data = []
|
||||
|
||||
def feed(self, data):
|
||||
self.data += data
|
||||
self.data.append(data)
|
||||
|
||||
def close(self):
|
||||
return json.loads(self.data, object_hook=object_hook)
|
||||
return json.loads(''.join(self.data), object_hook=object_hook)
|
||||
|
||||
|
||||
class Transport(xmlrpclib.Transport, xmlrpclib.SafeTransport):
|
||||
|
||||
Reference in new issue
Block a user