wlav / cppyy-backend

23 stars 27 forks source link

Reduce memory usage while downloading release #2

Closed c-w closed 2 years ago

c-w commented 2 years ago

This pull request optimizes the code to download the release tarball with two changes:

  1. Use context managers to automatically close the output file and HTTP response object removing the need for an explicit close call and handling the resource cleanup in cases of unexpected crashes, etc.
  2. Instead of reading the entire response into memory, download it in chunks and write to the output file as the chunks arrive, curtsy of shutil.copyfileobj.