Skip to content

Commit 74bbc3b

Browse files
authored
Merge pull request #3135 from rxxg/master
Perf improvement for file copies
2 parents d081627 + 083a630 commit 74bbc3b

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

dvc/system.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
import errno
22
import logging
33
import os
4+
import platform
45
import shutil
56

67
from dvc.compat import fspath
78
from dvc.exceptions import DvcException
89

9-
1010
logger = logging.getLogger(__name__)
1111

12+
if platform.system() == "Windows":
13+
try:
14+
import speedcopy
15+
16+
speedcopy.patch_copyfile()
17+
except ImportError:
18+
pass
19+
else:
20+
import sys
21+
22+
if sys.version_info < (3, 8):
23+
try:
24+
# Importing the module monkey-patches shutil.copyfile
25+
import pyfastcopy # noqa: F401
26+
except ImportError:
27+
pass
28+
1229

1330
class System(object):
1431
@staticmethod
@@ -90,8 +107,6 @@ def _reflink_linux(src, dst):
90107

91108
@staticmethod
92109
def reflink(source, link_name):
93-
import platform
94-
95110
source, link_name = fspath(source), fspath(link_name)
96111

97112
system = platform.system()

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ def run(self):
7575
"win-unicode-console>=0.5; sys_platform == 'win32'",
7676
"pywin32>=225; sys_platform == 'win32'",
7777
"networkx>=2.1,<2.4",
78+
"speedcopy>=2.0.1",
79+
"pyfastcopy>=1.0.3",
7880
"flatten-dict>=0.2.0",
7981
"texttable>=0.5.2",
8082
]

0 commit comments

Comments
 (0)