python - How to add large quantities of files to zip in a memory efficient way? -


I'm a bit new to optimize programs for memory efficiency, so this may be a little less preference: if I Want to add hundreds of files (possibly 100 MB +) in a zip, which method would be better to keep the system system available?

My existing method:

  zipfile.ZipFile (zip_name, " 

a ", compression = zipfile.ZIP_DEFLATED) as myzip: for file in zip_queue: myzip.write (file)

or like this:

 zip_queue file: zipfile.zipfile (zip_name, "a", compression = zipfile.ZIP_DEFLATED) as myzip: myzip.write (file)   

I followed I estimate that whenever she attaches the file, she flashes the memory every time, but the zip opening and the Do you spend more than memory cost each time just by keeping the file open?

Thank you!

The first way I will do it is to simply eliminate the same output file and avoid opening it again. For me, I suspect that every approach uses memory, the exact details of it are skeptical, and if this description has a lot of significance, then you have to type the code in something other than Python.

As a general rule, the file is slow from access memory, so I do not worry about memory usage here, unless you have a real problem that you can display .

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -