Skip to content

Commit 46122c4

Browse files
committed
ENH: fast reads on large gzip files
Fixes #209
1 parent ff2b545 commit 46122c4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

nibabel/openers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
import gzip
1414
import bz2
1515

16+
def _gzip_open(fileish, *args, **kwargs):
17+
# open gzip files with faster reads on large files using larger chuncks
18+
gzip_file = gzip.open(fileish, *args, **kwargs)
19+
gzip_file.max_read_chunk = 100 * 1024 * 1024 # 100Mb
20+
return gzip_file
21+
1622

1723
class Opener(object):
1824
""" Class to accept, maybe open, and context-manage file-likes / filenames

0 commit comments

Comments
 (0)