Skip to main content

Speed up shutil.copyfile by using sendfile system call

Project description

Latest Version Tests Status Coverage Supported Python versions License

pyfastcopy is a simple Python module that monkey patches the shutil.copyfile function of Python standard library to internally use the sendfile system call.

It can provide massive performance improvements for large file copy (the larger the file, the greater the performance gain). See here for some numbers.

Because shutil.copyfile is used by other fonctions in the shutil module, the following functions also automatically benefit from the performance boost:

  • shutil.copy

  • shutil.copy2

  • shutil.copytree

If sendfile is not available on your system or fails, the classic, slower chunk file copy is used, so there is no downside to using this module.

For more information, see my proposed patch for Python.

Usage

Just import the module:

import pyfastcopy

And then use the patched shutil.copyfile as usual:

shutil.copyfile(src, dst)

The ``sendfile`` system call does not exist on Windows, so importing this module will have no effect.

Installation

From PyPI (with PIP)

  1. If you don’t already have it, install pip for Python 3 (not needed if you are using Python >= 3.4)

  2. Install pyfastcopy: pip3 install pyfastcopy

  3. Enjoy fast fast copy when using shutil.copyfile, shutil.copy, shutil.copy2 or shutil.copytree

From source

  1. If you don’t already have it, install setuptools for Python 3

  2. Clone this repository: git clone https://github.com/desbma/pyfastcopy

  3. Install pyfastcopy: python3 setup.py install

  4. Enjoy fast fast copy when using shutil.copyfile, shutil.copy, shutil.copy2 or shutil.copytree

License

Python Software Foundation License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfastcopy-1.0.1.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file pyfastcopy-1.0.1.tar.gz.

File metadata

  • Download URL: pyfastcopy-1.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyfastcopy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 415fb8253331acff23989bfb289b1804ecf6e23a5168eafd2a4b28d20b69ceab
MD5 f1c42edf12f93f5f2da09bbe73ef8914
BLAKE2b-256 36f9c5dfa74d077fc483671a7150792977682805580d8f9d21569aad8cc849a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page