sending a large array over rpc call

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TheDerpie

How would I go about sending a large array over an RPC call I tried using to_json but it’s pretty inefficient

:bust_in_silhouette: Reply From: njamster

a large array

What do you mean by “large”? 100 elements? 10 000? 1 000 000? Also: What’s the content of your array? Does it contain mixed types? Strings? Integers? Floats?

I tried using to_json but it’s pretty inefficient

Define “pretty inefficient”. If you send the string representation of a huge array, it will take time, yes. However, there’s no magic solution for this. Depending on your use case, you might get away with sending the string in smaller chunks. The real question is why you have to send a huge array over the network in the first place though…

large as in 1 000 with arrays with the same size inside and those have integers

TheDerpie | 2020-06-02 09:53

If you know that array’s width in advance (or can send it alongside), consider sending the array as an 1D array instead of a 2D array. This should be significantly faster to serialize to JSON, and will let you loop much faster over the array.

Calinou | 2020-06-02 14:36