From 376cbcce263a67ecb9c28a08234a13a916d4cf42 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Wed, 15 May 2019 23:50:31 -0700 Subject: [PATCH] Use buffered IO free ~10% speedup on read, probably similar on write --- masque/file/gdsii.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/masque/file/gdsii.py b/masque/file/gdsii.py index 8b04bec..37b1a22 100644 --- a/masque/file/gdsii.py +++ b/masque/file/gdsii.py @@ -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