Can we inter-convert between numpy arrays and list[Vec3], list[Vec2], list[Vec4] for speed?

Suppose I have a large number of Vec3 (or Vec2 or Vec4) eg in a list.
If I want to transform them all (eg translate, rotate) etc I have to iterate over a list in Python.
If I can convert them to a numpy array, the transform can be much faster.
Is there a way to do this?

Where do you see that numpy supports vector types?

https://numpy.org/doc/stable/user/basics.types.html

You can always unpack such a vector.

from panda3d.core import Vec3
import numpy as np

p3d_vector = Vec3(7, 2, 0)
np_vec3 = np.array(p3d_vector)

print(np_vec3)

out:

[7. 2. 0.]

Morning.

Probably I wasn’t clear.

Say I have a function that operates on a collection of Vec3

some_func(arg: list[Vec3]):

iterate over the list, do something for each item in the list

I was wondering if this would be both easier and faster with a 2-d numpy array:

npa = create_vectors() # 2d numpy array, first dim is num vectors, second dim is 0=x, 1=y, 2=z

then

some_func(npa)

now can use numpy operations

eg translate and scale etc

very fast (get numpy iteration in c++, not python list iteration)

does anything provide that in panda3d?
eg for Vec3, Vec2 etc?

Thanks

Panda has a TransformState class, which has these functions.
https://docs.panda3d.org/1.10/python/reference/panda3d.core.TransformState