Skip to content

Commit 07f715e

Browse files
committed
init blosc
1 parent d7aec32 commit 07f715e

File tree

3 files changed

+1011
-1003
lines changed

3 files changed

+1011
-1003
lines changed

numcodecs/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
# flake8: noqa
33
from __future__ import absolute_import, print_function, division
4+
import multiprocessing
5+
import atexit
46

57

68
from numcodecs.version import version as __version__
@@ -18,8 +20,14 @@
1820
register_codec(LZMA)
1921

2022
try:
23+
from numcodecs import blosc as _blosc
2124
from numcodecs.blosc import Blosc
2225
register_codec(Blosc)
26+
# initialize blosc
27+
ncores = multiprocessing.cpu_count()
28+
_blosc.init()
29+
_blosc.set_nthreads(min(8, ncores))
30+
atexit.register(_blosc.destroy)
2331
except ImportError: # pragma: no cover
2432
pass
2533

0 commit comments

Comments
 (0)