Which is smaller? Vector3.new(1,2,3) or {1,2,3}

Which has a smaller size/footprint?
A Vector3 or a table?

What if you had a UDim2?
Is a UDim2.new(1,2,3,4) any better than {1,2,3,4}?

I’m taking about raw byte size, not use cases.

2 Likes

The vector is smaller. Vectors store only three 32-bit floats, so there will be an accuracy degradation between it and a table of 3 numbers. With that said, it probably doesn’t make a big difference their size unless you have a loooooot.

UDim2 should also be smaller. Generally the build in types are their raw memory representation.

10 Likes

Vector3s and other similar types are going to become built-in types in Luau soon anyways, so I’d recommend just sticking with those.

I don’t have the exact quote but I found it on https://roblox.github.io/luau

3 Likes