Message355615
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. |
|
Date |
User |
Action |
Args |
2019-10-29 05:46:54 | dhillier | set | recipients:
+ dhillier, serhiy.storchaka |
2019-10-29 05:46:54 | dhillier | set | messageid: <1572328014.34.0.723678747799.issue37523@roundup.psfhosted.org> |
2019-10-29 05:46:54 | dhillier | link | issue37523 messages |
2019-10-29 05:46:54 | dhillier | create | |
|