我注意到,如果我使用h5py库而不是pytables库,则编写.h5文件的时间会更长。是什么原因?当阵列的形状以前已知时,也是如此。此外,我使用相同的块大小,没有压缩过滤器。
以下脚本:
import h5py
import tables
import numpy as np
from time import time
dim1, dim2 = 64, 1527416
# append columns
print("PYTABLES: append columns")
print("=" * 32)
f = tables.open_file("/tmp/test.h5", "w")
a = f.create_earray(f.root, "time_data", tables.Float32Atom(), shape=(0, dim1))
t1 = time()
zeros = np.zeros((1, dim1), dtype="float32")
for i in range(dim2):
a.append(zeros)
tcre = round(time() - t1, 3)
thcre = round(dim1 * dim2 * 4 / (tcre * 1024 * 1024), 1)
print("Time to append %d columns: %s sec (%s …Run Code Online (Sandbox Code Playgroud)