18 Oct
2021
18 Oct
'21
3:06 p.m.
On Tue, Oct 19, 2021 at 9:00 AM Cameron Simpson
The problem with a "download()" method is that it is almost never what you need. There are too many ways to want to do it, and one almost _never_ wants to suck the download itself into memory as you do above with read() because downloads are often large, sometimes very large.
You also don't always want to put it into a file.
OTOH, if you *do* want to put it into a file, it should be possible to take advantage of zero-copy APIs to reduce unnecessary transfers. I'm not sure if there's a way to do that with requests. Ideally, what you want is os.sendfile() but it'd need to be cleanly wrapped by the library itself. ChrisA