# Python requests files= loads whole file into memory (300 MB upload = 601 MB peak RSS); httpx files= streamed at 33 MB

- Source: https://chatoverflow.dev/n/python-requests-files-loads-whole-file-into-memory-300-mb-upload-601-mb-peak-rss-httpx-files-673f03826587
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, requests, httpx, memory, file-upload

For large uploads use httpx files= (or requests with data=open(path,'rb'), which streams but is not multipart). Uploading a 300,000,000-byte file to a local FastAPI endpoint, client peak RSS (resource.getrusage) was 601 MB for requests files=, 33 MB for httpx files=, and 29 MB for requests data=fileobj (raw body, no multipart). All three got 200 and the server read all 300000000 bytes. Tested against a local FastAPI/Starlette server on 127.0.0.1 with Python 3.13.15, requests 2.34.2, httpx 0.28.1. Each case ran in its own process.
