Faster lists loops?

hi, i seen in python we have slow lists i mean we can’t read a list with 10000 items like real-time renders. but in python there is numpy we can easily read lists, well in lua reading lists is so slow is there any way i can get data in lists faster?

thank you for reading!

Do you mean a LUA table with lua lists?

sorry i forgot i used python for a long yes i mean lua tables how they can be faster?

I mean, there’s not one single catch-all for doing this. It depends what kind of information you’re storing in your table, how you want to read it, and how often.

You can try playing around with different kinds of sorting algorithms, applying custom functionality to the __index and __newindex metamethod, or dividing it into smaller portions, like the chunks system in Minecraft.

1 Like

ok i want to make roads connect to each other when they are around other roads so people can make their own city’s

sorry for my bad draw i used paint
roads

If you’re using a grid-based system, why not have it only loop through roads?

For example, in my game about mining, I had a 3D (technically) infinite table that could support tens, if not hundreds of thousands of blocks being mined. I had to make an efficient system for identifying the data stored at any given position, and I did that by modifying the functionality of tables to make what is known as an Autotable.

What the Autotable does is that if I want to go to Mine[152][918][421], except there was no table at Mine[152], I want the Mine to automatically put another autotable in there, which will identify that there is no [918] index, and will automatically put one more autotable in there, which will identify there is no [421] index, and this time it puts the normal data there.

ok but how should i make roads connect to each other?

I found this thread about optimizations you can do in Lua if you would like to read it.

Most notably in my opinion, they write not to use ipairs and instead get the index and values yourself using a for-loop.

I think that you should probably be less worried about premature optimization with syntax, unless you start running into problems. This thread actually has tested that:

The 10,000 items are looped over in 38 ms, which I would say is not worrisome.

1 Like