Attention | Topic was automatically imported from the old Question2Answer platform. | |
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
Attention | Topic was automatically imported from the old Question2Answer platform. | |
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
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