Fastest way to parse JSON strings into numpy arrays

前端 未结 3 756
野趣味
野趣味 2021-02-05 15:08

I have huge json objects containing 2D lists of coordinates that I need to transform into numpy arrays for processing.

However using json.loads followed wi

3条回答
  •  春和景丽
    2021-02-05 15:54

    The simplest answer would just be:

    numpy_2d_arrays = np.array(dict["rings"])
    

    As this avoids explicitly looping over your array in python you would probably see a modest speedup. If you have control over the creation of json_input it would be better to write out as a serial array. A version is here.

提交回复
热议问题