Skip to content

Conversation

@NewUserHa
Copy link
Contributor

@NewUserHa NewUserHa commented Dec 8, 2025

Clarify the behavior of efficiency of shutil.copyfile and shutil.copy2 on Windows.

Fixs: #142407


📚 Documentation preview 📚: https://cpython-previews--142408.org.readthedocs.build/

Clarify the behavior of shutil.copyfile and shutil.copy2 on Windows, including buffer size and efficiency.
On Windows :func:`shutil.copyfile` uses a bigger default buffer size (1 MiB
instead of 64 KiB) and a :func:`memoryview`-based variant of
:func:`shutil.copyfileobj` is used.
:func:`shutil.copyfileobj` is used, which is still read and write in a loop.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:func:`shutil.copyfileobj` is used, which is still read and write in a loop.
:func:`shutil.copyfileobj` is used, which is still reads and writes in a loop.

Grammar.

Comment on lines +544 to +545
:func:`shutil.copy2` uses native call ``CopyFile2`` on windows and it is the most
efficient and support copy-on-write, but preserve the metadata.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:func:`shutil.copy2` uses native call ``CopyFile2`` on windows and it is the most
efficient and support copy-on-write, but preserve the metadata.
:func:`shutil.copy2` uses the native ``CopyFile2`` call on Windows, which is the most
efficient method, supports copy-on-write, and preserves metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants