How much memory does a p5.Vector variable take up compared to an integer variable?

I’m writing something that involves image manipulation. I decided to use an array of p5.Vectors because I could store the x and y coordinates of pixels more easily. I could just as easily create 2 integer arrays (coordinateX and coordinateY) that would do the same thing.

I do want to be efficient and not take up computer resources unnecessarily.

Should I switch from the p5.Vector array to 2 integer arrays instead?

Thanks.

1 Like

If you’re not invoking any of the p5.Vector’s methods there’s not much reason to use it.

You can simply go w/ an Uint16Array for example:

You can store all the x values in the even indices, and all the y values in the odd indices.

1 Like