Windows xcopy patch for shutil.copyfile, based on pyfastcopy
Project description
speedcopy
Patched python shutil.copyfile using native call CopyFile2 on windows to accelerate
transfer on windows shares. On Linux, it issues special ioctl command CIFS_IOC_COPYCHUNK_FILE to enable server-side copy.
This works only when both source and destination files are on same SMB1(CIFS)/2/3 filesystem.
See https://wiki.samba.org/index.php/Server-Side_Copy
Installation
Add speedcopy to PYTHONPATH or:
pip install speedcopy
Usage
If you want to monkeypatch shutil.copyfile() then:
import shutil
import speedcopy
speedcopy.patch_copyfile()
# your code ...
shutil.copyfile(src, dst)
This will make last call to use speedcopy.
Direct use:
import speedcopy
# some code ...
speedcopy.copyfile(src, dst)
There is also debug mode enabled by setting speedcopy.SPEEDCOPY_DEBUG = True. This will print more information during runtime.
Benchmark
Windows
| Filesize | Python | Speedcopy | Factor |
|---|---|---|---|
| 1 | 0.0797 | 0.0222 | 3.59 |
| 2 | 0.1702 | 0.0254 | 6.69 |
| 4 | 0.3257 | 0.0271 | 12.01 |
| 8 | 0.6729 | 0.0337 | 19.94 |
| 16 | 1.335 | 0.0384 | 34.72 |
| 32 | 2.3612 | 0.0625 | 37.72 |
| 64 | 57.4549 | 0.9758 | 58.88 |
| 128 | 10.9294 | 0.1669 | 65.47 |
| 256 | 20.3843 | 2.276 | 8.96 |
| 512 | 35.9462 | 3.9966 | 8.99 |
| 1024 | 65.6285 | 28.0291 | 2.34 |
Linux
| Filesize | Python | Speedcopy | Factor |
|---|---|---|---|
| 1 | 0.0682 | 0.0099 | 6.88 |
| 2 | 0.0894 | 0.0105 | 8.51 |
| 4 | 0.1337 | 0.012 | 11.14 |
| 8 | 0.1922 | 0.0145 | 13.25 |
| 16 | 0.2853 | 0.0193 | 14.78 |
| 32 | 0.4724 | 0.0288 | 16.4 |
| 64 | 8.0071 | 0.4724 | 16.94 |
| 128 | 1.3338 | 0.2311 | 5.77 |
| 256 | 2.6599 | 0.4788 | 5.55 |
| 512 | 5.3798 | 0.9796 | 5.49 |
| 1024 | 10.3328 | 2.9180 | 3.54 |
Note that Windows and Linux timing do not correlate, they are taken from different systems. Notice the spike on 64 Mb size file on both of them. Also note that these figures are not taken from production grade hardware and setup and can be completely off at other places.
You can test it yourself with included benchmark.py (and this will take some time as values are measured multiple times and then averaged).
Todo
- Better error handling
- Other platforms support
- Conform behaviour to original
shutil.copyfile() - Review benchmark code
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file speedcopy-2.0.0.tar.gz.
File metadata
- Download URL: speedcopy-2.0.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8c18a6042dc2fc5d717ebc7f7d2fe3b69fe2a78e649ca78c99e15fc0fe5bceb
|
|
| MD5 |
5cbc5583f12890535af8114c27acc363
|
|
| BLAKE2b-256 |
af1694711261d1530e528028597b972cae2dbab6abc797ae9d267d8927cd4ec8
|
File details
Details for the file speedcopy-2.0.0-py3-none-any.whl.
File metadata
- Download URL: speedcopy-2.0.0-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27a948025834e2def9e828f9bc13bcc51dd15f9d3785392c8b8cd5035a402765
|
|
| MD5 |
e43cbc839bde6a59aaf96179e9e5a531
|
|
| BLAKE2b-256 |
16ad30e2e021db68bab23e46a530eee3043b5398f6878724105f035fb8fb9cd1
|