This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dhillier
Recipients dhillier, serhiy.storchaka
Date 2019-10-29.05:46:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1572328014.34.0.723678747799.issue37523@roundup.psfhosted.org>
In-reply-to
Content
Here's the script I used for profiling and the results I observed with and without the closed check in read:

import zipfile

test_zip = "time_test.zip"
test_name = "test_name.txt"

with zipfile.ZipFile(test_zip, "w") as zf:
    zf.writestr(test_name, "Hi there! " * 300)

with zipfile.ZipFile(test_zip) as zf:
    for i in range(100000):
        zf.read(test_name)

# Current code (no closed check), three different profiling sessions:
# ncalls  tottime  percall  cumtime  percall filename:lineno(function)
# 100000    0.612    0.000    6.638    0.000 zipfile.py:884(read)
# 100000    0.598    0.000    6.489    0.000 zipfile.py:884(read)
# 100000    0.600    0.000    6.485    0.000 zipfile.py:884(read)

# With closed check, three different profiling sessions:
# ncalls  tottime  percall  cumtime  percall filename:lineno(function)
# 100000    0.632    0.000    6.587    0.000 zipfile.py:884(read)
# 100000    0.623    0.000    6.564    0.000 zipfile.py:884(read)
# 100000    0.638    0.000    6.700    0.000 zipfile.py:884(read)

-------

I based this change on the what BytesIO does: https://github.com/python/cpython/blob/master/Lib/_pyio.py#L912

Let me know if you want me to make any changes.
History
Date User Action Args
2019-10-29 05:46:54dhilliersetrecipients: + dhillier, serhiy.storchaka
2019-10-29 05:46:54dhilliersetmessageid: <1572328014.34.0.723678747799.issue37523@roundup.psfhosted.org>
2019-10-29 05:46:54dhillierlinkissue37523 messages
2019-10-29 05:46:54dhilliercreate