use 'functools.partial' in '_build_cleanfunc' when possible

makes calls to the returned function a slight bit faster (~10%)
This commit is contained in:
Mike Fährmann
2021-06-20 23:32:07 +02:00
parent e661607e8b
commit 79b7ee2712

View File

@@ -851,8 +851,8 @@ class PathFormat():
def func(x, c=chars, r=repl):
return x.replace(c, r)
else:
def func(x, sub=re.compile("[" + chars + "]").sub, r=repl):
return sub(r, x)
return functools.partial(
re.compile("[" + chars + "]").sub, repl)
return func
def open(self, mode="wb"):