Skip to content

Conversation

xiexianbin
Copy link

This commit addresses an issue where sending large data with httpx.Client was extremely slow. The problem was that the entire data payload was being loaded into memory and sent in a single operation.

This fix refactors the sending process for iterable bytes types to use a chunked approach with yield, which significantly improves performance and reduces memory usage for large payloads.

Summary

pip install httpx==0.27.0

test case ref encode/httpcore#1029, close issue #3660

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@xiexianbin xiexianbin force-pushed the fix/slow-for-big-body branch from 07d4d66 to c7a8790 Compare September 7, 2025 14:38
This commit addresses an issue where sending large data with httpx.Client was
extremely slow. The problem was that the entire data payload was being loaded
into memory and sent in a single operation.

This fix refactors the sending process for iterable bytes types to use a
chunked approach with `yield`, which significantly improves performance and
reduces memory usage for large payloads.

Signed-off-by: xiexianbin <me@xiexianbin.cn>
@xiexianbin xiexianbin force-pushed the fix/slow-for-big-body branch from c7a8790 to 78377fa Compare September 7, 2025 15:03
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.

1 participant