python / python/cpython

Support `copy()` for `zipfile`

Open
#151,824 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

Currently, copying an entry within a ZIP file is cumbersome due to the lack of support for simultaneous reading and writing. The implementer must either:

  • Read the entire entry and write afterwards (which is memory-intensive and inefficient for large files), or
  • Use a temporary file for buffered copying.

Both approaches are more complex and less performant, due to the need to decompress and recompress data.

It would be much more performant and friendly by implementing a copy() method, using the similar internal buffered copying technique introduced by #134627 with the internal _ZipRepacker.

This also opens the door to support an efficient move() operation, composed of copy(), remove(), and optionally repack().

Linked PRs
  • gh-151825

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the zipfile module's entry and the internal _ZipRepacker approach introduced by issue #134627. The change should provide efficient copying of an entry while the archive is open for reading and writing, with behavior and edge cases established before implementation. Linked PR gh-151825 indicates that work is already underway.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.