[英]Decode base64 array at specific index positions
I handle a big number of XML files, each of which stores a float64 array in the form of a base64 string.我处理了大量的 XML 文件,每个文件都以 base64 字符串的形式存储一个 float64 数组。 For each of these files, I would like to access the value of its array at a specific index without loading the whole array.对于这些文件中的每一个,我想在不加载整个数组的情况下访问其数组在特定索引处的值。 I wish to do this in Python.我希望在 Python 中执行此操作。
Currently, I decode the entire string and then access the value at given index, but I am looking for a much faster method.目前,我解码整个字符串,然后访问给定索引处的值,但我正在寻找一种更快的方法。
As I understand, each float uses 8 bytes to store.据我了解,每个浮点数使用 8 个字节来存储。 Each 3-bytes of binary data are mapped to 4 base64 chars.每 3 字节的二进制数据映射到 4 个 base64 字符。 So, in order to access i-th float, you'll need to:因此,为了访问第 i 个浮点数,您需要:
(i * 8 / 3) * 4
to (i * 8) / 3) * 4 + 4
从索引(i * 8 / 3) * 4
到(i * 8) / 3) * 4 + 4
获取 base64 字符(i * 8) % 3
bytes先删除(i * 8) % 3
个字节
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.