Use buffered IO
free ~10% speedup on read, probably similar on write
This commit is contained in:
parent
a461446059
commit
376cbcce26
@ -124,7 +124,7 @@ def writefile(patterns: List[Pattern] or Pattern,
|
||||
else:
|
||||
open_func = open
|
||||
|
||||
with open_func(path, mode='wb') as stream:
|
||||
with io.BufferedWriter(open_func(path, mode='wb')) as stream:
|
||||
results = write(patterns, stream, *args, **kwargs)
|
||||
return results
|
||||
|
||||
@ -218,7 +218,7 @@ def readfile(filename: str or pathlib.Path,
|
||||
else:
|
||||
open_func = open
|
||||
|
||||
with open_func(path, mode='rb') as stream:
|
||||
with io.BufferedReader(open_func(path, mode='rb')) as stream:
|
||||
results = read(stream, *args, **kwargs)
|
||||
return results
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user