ndarray 比 recarray 访问快吗?ndarray、recarray

2023-09-08 08:44:48 作者:古城旧巷旧人不覆

我能够将我的 recarray 数据复制到 ndarray,进行一些计算并返回带有更新值的 ndarray.

I was able to copy my recarray data to a ndarray, do some calculations and return the ndarray with updated values.

然后,我在 numpy.lib.recfunctions 中发现了 append_fields() 功能,并认为将 2 个字段简单地附加到我原来的 recarray 会更聪明保存我的计算值.

Then, I discovered the append_fields() capability in numpy.lib.recfunctions, and thought it would be a lot smarter to simply append 2 fields to my original recarray to hold my calculated values.

当我这样做时,我发现操作要慢得多.我不需要计时,基于 ndarray 的过程需要几秒钟,而使用 recarray 需要一分钟以上,而且我的测试数组很小,