summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorJan Hicken <janhicken@users.noreply.github.com>2024-11-10 14:57:24 (GMT)
committerGitHub <noreply@github.com>2024-11-10 14:57:24 (GMT)
commit160758a574d12bf0d965d8206136e7da4f4fd6c3 (patch)
tree1c3d94bd8c6c80738334ae0bbc64bd70081846e7 /Misc
parent450db61a78989c5a1f1106be01e071798c783cf9 (diff)
downloadcpython-160758a574d12bf0d965d8206136e7da4f4fd6c3.zip
cpython-160758a574d12bf0d965d8206136e7da4f4fd6c3.tar.gz
cpython-160758a574d12bf0d965d8206136e7da4f4fd6c3.tar.bz2
gh-126565: Skip `zipfile.Path.exists` check in write mode (#126576)
When `zipfile.Path.open` is called, the implementation will check whether the path already exists in the ZIP file. However, this check is only required when the ZIP file is in read mode. By swapping arguments of the `and` operator, the short-circuiting will prevent the check from being run in write mode. This change will improve the performance of `open()`, because checking whether a file exists is slow in write mode, especially when the archive has many members.
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS.d/next/Library/2024-11-08-11-06-14.gh-issue-126565.dFFO22.rst1
1 files changed, 1 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2024-11-08-11-06-14.gh-issue-126565.dFFO22.rst b/Misc/NEWS.d/next/Library/2024-11-08-11-06-14.gh-issue-126565.dFFO22.rst
new file mode 100644
index 0000000..2285857
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-11-08-11-06-14.gh-issue-126565.dFFO22.rst
@@ -0,0 +1 @@
+Improve performances of :meth:`zipfile.Path.open` for non-reading modes.