Improve the performance of HostingServiceClient._build_form_data
Review Request #8910 — Created April 21, 2017 and submitted
The method in question was doing multiple string concatenations with
+=
, which is very inefficient for large number of operations becuase
each operation results in a memory allocation. We now build a single
string with string interpolation for each field and file passed in and
join all the blobs together, which will require only a single memory
allocation for the final string, instead ofO(|fields| + |files|)
allocations.
Ran unit tests.
Description | From | Last Updated |
---|---|---|
While here, we should also make this a byte string. Here and below. |
chipx86 | |
Let's just make this: if files: Covers None and empty dictionaries. |
chipx86 | |
Let's also use six.iteritems here, pull out the value only once and during iteration, to speed things up a little … |
chipx86 | |
Trailing comma. |
chipx86 | |
We should check if these are unicode and if so, encode to utf-8 before formatting. |
david | |
Same here. |
david | |
Can we switch these two lines to match the order in the return statement? |
david | |
Should be b''.join(...) |
david |
- Change Summary:
-
Addressed Christian's issues
- Diff:
-
Revision 2 (+34 -20)
Checks run (3 succeeded)
- Change Summary:
-
Addressed David's issues
- Diff:
-
Revision 3 (+52 -22)