Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有大小不超过 20Mb 的二进制文件,其中有一个标题部分,然后是一个包含 uchars 序列的数据部分。我有 Numpy、SciPy 等,每个库都有不同的数据加载方式。对于我应该使用的最有效方法有什么建议吗?
如果性能很关键,请使用struct模块,或者可能使用 C 编写的自定义模块。
struct应该适用于 header 部分,而 numpy 的memmap对 data 部分将是有效的,如果你要在 numpy 中操作它。这里没有必要强调不一致。两种方法都兼容,只需为每项工作使用正确的工具。
bdec似乎很有希望。
我发现这array.fromfile是同类数据最快的方法。
array.fromfile