I had to check, but there is not a bug (by definition), more a difference in expectation.
For what ever reason, someone decided that the paging should be with the fastest dimension.
There is a bug that doesn’t allow the user to change the paging/selection of the visual rows/cols and dimensions for attributes, Datasets have the OpenAs option.
File a GitHub issue in the hdfview project and I will try to rectify this for the upcoming releases.
The biggest 2d array of doubles I create for an attribute is 90x90. After that I get error “Unable to create attribute (object header message is too large)”.
A very informal comparison, with both run in release mode using VS 2022 is then:
Python:
f = h5py.File("arraytest.h5", "w")
d = 90
arr = np.random.rand(d,d)
stopwatch = Stopwatch();
stopwatch.start();
for x in range(0, 1000):
f.attrs["py-array-{0}x{1}-{2}".format(d,d,x)] = arr
stopwatch.stop();
print(stopwatch.elapsed)
Takes 9.3 seconds.
My C# code
Random r = new Random(Environment.TickCount);
int d = 90;
var sw = new Stopwatch();
var array = Enumerable.Range(0, d * d).Select(i => r.NextDouble()).ToArray();
sw.Start();
for (int i = 0; i < 1000; i++)
{
file.WriteUnmanagedAttribute($"c#-{d}x{d}-{i}", array, new long[] { d, d });
}
Console.WriteLine(sw.ElapsedMilliseconds);
For clarification, that’s an attribute size limitation in the earliest file format spec. (which is the default). 64,800 bytes is pretty close to 64KiB. This restriction was dropped in later attribute layouts.
Then this doesn’t take effect on the file and creating large attributes fail as before. If I now create a group on the file I can create large attributes on the group.
Yes, we had several performance improvements post-1.10.6 (2019-12-23) vs. 1.12.2 (
2022-04-27). We are preparing HDF.PInvoke 1.10.9, which should be a tad faster.