How to set cache settings while using h5py high level interface?

前端 未结 3 1662
忘掉有多难
忘掉有多难 2020-12-17 04:36

I\'m trying to increase cache size for my HDF5 files, but it doesn\'t seem to be working. This is what I have:

import h5py

with h5py.File(\"test.h5\", \'w\'         


        
3条回答
  •  被撕碎了的回忆
    2020-12-17 05:02

    As of h5py version 2.9.0, this behavior is now available directly through the main h5py.File interface. There are three parameters that control the "raw data chunk cache" — rdcc_nbytes, rdcc_w0, and rdcc_nslots — which are documented here. The OP was trying to adjust the rdcc_nbytes setting, which can now simply be done as

    import h5py
    
    with h5py.File("test.h5", "w", rdcc_nbytes=5242880) as fid:
        # Use fid for something here
    

    The only difference is that you have to know how much space you actually need, rather than just multiplying by 5 as the OP wanted. The current default values are the same as the OP found. Of course, if you really wanted to do this programatically, you could just open it once, get the cache, close it, and then reopen with the desired parameters.

提交回复
热议问题