Time comparison between sin and cos operations on lists and numpy array

I have used %%time to compare the time required for sin and cos operations for lists and NumPy array. But I have noticed that sin and cos operations on lists take less time than NumPy array operations. Please guide me if I am using the wrong programming approach.

Hi Snehal,
This looks strange, but I’m pretty sure that it’s the case with a smaller array/list size.
I would suggest you to create a random list of ~1000 numbers, and then check the performance.
Because there can be overheads sometimes which lead to take more time in numpy.

1 Like

Thank you so much, sir. I have tried it and it works…

1 Like