Learn more about these different git repos.
Other Git URLs
ec1e98d
@@ -38,6 +38,7 @@
import pwd
import random
import re
+ import shutil
import socket
import struct
import sys
@@ -2028,8 +2029,7 @@
resp = request_with_retry().get(url, stream=True)
try:
- for chunk in resp.iter_content(chunk_size=8192):
- fo.write(chunk)
+ shutil.copyfileobj(resp.raw, fo)
finally:
resp.close()
resp.raise_for_status()
It is a bit faster. With a local server it gives 70% of original time. For real network the gain would be smaller, but doesn't hurt to have it there.
I'm curious why one is faster, and whether that will be true across different versions of python and requests
I suspect that at least buffer is much larger (8k vs 64k), but I've not tested the former with 64k buffer.
https://github.com/python/cpython/blob/3.13/Lib/shutil.py#L47
It is a bit faster. With a local server it gives 70% of original time.
For real network the gain would be smaller, but doesn't hurt to have it
there.