From c81a4f93a0440153301e63e541f91cd864594867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 5 Mar 2016 17:24:12 +0100 Subject: [PATCH] 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 --- tryton/jsonrpc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tryton/jsonrpc.py b/tryton/jsonrpc.py index 56fd4dd066..edbe882e76 100644 --- a/tryton/jsonrpc.py +++ b/tryton/jsonrpc.py @@ -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):