it is said that the numpy is much faster than python,but why not in this script:

Obviously,the python code is ten times faster than numpy code,what is wrong?
To get a numpy array from a Vector List, you can use the asNumpyArray method. To get a Color List from a numpy array, you can use the fromNumpyArray method. This should reduce the python overhead significantly.
To get a numpy array from a Vector List, you can use the
asNumpyArraymethod. To get a Color List from a numpy array, you can use thefromNumpyArraymethod. This should reduce the python overhead significantly.
Is asNumpyArray method of Vector3DList ?
@harisreedhar Yes, all numeric lists in Animation Nodes have an asNumpyArray method. Similarly, All numeric list classes have a fromNumpyArray class method.
@harisreedhar Yes, all numeric lists in Animation Nodes have an
asNumpyArraymethod. Similarly, All numeric list classes have afromNumpyArrayclass method.
Thanks, Is there any way to know available functions of class?
@harisreedhar If you mean in python in general, you can use the dir function, which will return a list of the names of all the methods and attributes of an object. For instance:
>>> a = [1, 2, 3]
>>> dir(a)
['sort', 'reverse', 'remove', 'pop', 'insert', 'index', 'extend', 'count', 'copy', 'clear', 'append', '__subclasshook__', '__str__', '__sizeof__', '__setitem__', '__setattr__', '__rmul__', '__reversed__', '__repr__', '__reduce_ex__', '__reduce__', '__new__', '__ne__', '__mul__', '__lt__', '__len__', '__le__', '__iter__', '__init_subclass__', '__init__', '__imul__', '__iadd__', '__hash__', '__gt__', '__getitem__', '__getattribute__', '__ge__', '__format__', '__eq__', '__doc__', '__dir__', '__delitem__', '__delattr__', '__contains__', '__class__', '__add__']
@harisreedhar If you mean in python in general, you can use the
dirfunction, which will return a list of the names of all the methods and attributes of an object. For instance:>>> a = [1, 2, 3] >>> dir(a) ['sort', 'reverse', 'remove', 'pop', 'insert', 'index', 'extend', 'count', 'copy', 'clear', 'append', '__subclasshook__', '__str__', '__sizeof__', '__setitem__', '__setattr__', '__rmul__', '__reversed__', '__repr__', '__reduce_ex__', '__reduce__', '__new__', '__ne__', '__mul__', '__lt__', '__len__', '__le__', '__iter__', '__init_subclass__', '__init__', '__imul__', '__iadd__', '__hash__', '__gt__', '__getitem__', '__getattribute__', '__ge__', '__format__', '__eq__', '__doc__', '__dir__', '__delitem__', '__delattr__', '__contains__', '__class__', '__add__']
Thank you
To get a numpy array from a Vector List, you can use the
asNumpyArraymethod. To get a Color List from a numpy array, you can use thefromNumpyArraymethod. This should reduce the python overhead significantly.
Thank you very much! does the "GenericList " have the asNumpyArraymethod?
GenericList is a python lists, not a CList, so no.
GenericList is a python lists, not a CList, so no.
much appreciate! another question is that can we write a Numpy array in .pyx file like this:
cdef nd.array array_b = Vector3DList.asNumpyArray(vectors)
or how can we cdef a numpy array in the cython?
thank you!
@kdsin23 Read the Cython documentation on the topic:
https://cython.readthedocs.io/en/latest/src/tutorial/numpy.html
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
To get a numpy array from a Vector List, you can use the
asNumpyArraymethod. To get a Color List from a numpy array, you can use thefromNumpyArraymethod. This should reduce the python overhead significantly.