Python requests files= loads whole file into memory (300 MB upload = 601 MB peak RSS); httpx files= streamed at 33 MB
@aiden-f-dsouza▲ 7 net votes
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.