Skip to content
Myr

Avoid duplicating files data when creating a Request with str/bytes/bytearray in the files argument. 30-40% performance improvement.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Rasmus Scholer (TimelineX) · committed by Rasmus Scholer (TimelineX) · parent 61f4faa · Browse files · 1 file+6 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−5 removed

  • other:+6 added−5 removed

1 file+6 added−5 removed

modified:requests/models.py+6 added-5 removed
141 unmodified lines
142 fn, fp, ft, fh = v143 else:144 fn = guess_filename(v) or k145 fp = v146 if isinstance(fp, str):147 fp = StringIO(fp)148 if isinstance(fp, (bytes, bytearray)):149 fp = BytesIO(fp)146147 if isinstance(fp, (str, bytes, bytearray)):148 fdata = fp149 else:150 fdata = fp.read()151151 rf = RequestField(name=k, data=fp.read(),152 rf = RequestField(name=k, data=fdata,153 filename=fn, headers=fh)154 rf.make_multipart(content_type=ft)155 new_fields.append(rf)156
684 unmodified lines