Skip to content

Optimize multipart request body allocations - #101

Merged
woswos merged 6 commits into
masterfrom
rs-multipart-encode-opt
Sep 1, 2026
Merged

woswos merged 6 commits into
masterfrom
rs-multipart-encode-opt

Conversation

@rschlaikjer

Copy link
Copy Markdown
Contributor

The requests library hands multipart fields to urllib3, which appends each part to a BytesIO.
This reallocates and copies on each resize, and the final getvalue() copies again.
Joining a list of binary parts instead computes the final size up front, and copies only once.

@rschlaikjer
rschlaikjer requested review from woswos and ziyan August 27, 2026 09:08

@woswos woswos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes!

@woswos

woswos commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

Pipeline #2086969 and Pipeline #2087193

@woswos
woswos merged commit 0138a70 into master Sep 1, 2026
1 check passed
@rschlaikjer
rschlaikjer deleted the rs-multipart-encode-opt branch September 1, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants