0 votes

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

asked Jun 1 in Engine by TheDerpie (12 points)

1 Answer

0 votes

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...

answered Jun 1 by njamster (8,768 points)

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

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.