Skip to content

shutil.copyfile should use ReFS block-level linking on Windows (by invoking CopyFileW) #137074

@Dico200

Description

@Dico200

Bug report

Bug description:

shutil.copyfile("./scratch.txt", "./target.txt")

copyfile for copies within a single ReFS volume (or Dev Drive) on Windows 11 does not take advantage of block-level linking capability present in ReFS file system. On the other hand, the kernel automatically does so when you invoke CopyFileW these days. C#/.NET use kernel functions for file copy APIs and automatically take advantage of this too.

Python does not offer an API that takes advantage of block-level linking except for directly invoking CopyFileW using windlls.kernel32 from ctypes.

https://docs.python.org/3/library/shutil.html#shutil-platform-dependent-efficient-copy-operations
CopyFileW should be used instead of streaming data from one file to another, at least in circumstances where block-level linking is possible.

Relevant code:

with open(src, 'rb') as fsrc:

CPython versions tested on:

3.9

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowsstdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy