+ 2
I am wondering why python community insists to support, advertise, and glory numpy package?
The built-in data structure in python (list, set, tuple, and dictionary) are very superior and robust than array which numpy uses. What are advantages of array over the aforementioned data structure? Please, let me know. I am shocked.
6 ответов
+ 12
Numpy is a powerful and efficient package that provides many advantages for numerical computing tasks.
>NumPy arrays are much faster than built-in Python data structures for numerical operations
>NumPy arrays are more memory-efficient than Python's built-in data structures
>NumPy provides a wide range of built-in functions and methods for working with arrays, including mathematical functions, etc.
there's much more about numpy for better understanding Google it.
+ 4
Abdulfattah Alhazmi
it's the other way around...
Try doing complex matrix operations with lists.
(it's not a conspiracy, just a solution to a problem of Python's limitation)
Maybe you're just venting your personal frustration in learning Numpy. But the "I'm not dumb, you're all dumb" attitude will not get you anywhere.
+ 4
As much as anything else, Numpy runs a lot faster than even the Python Standard library.
+ 1
Thank you @Snehil and @Jonathan Shiell for your clear, respectful answer. I hope that @Bob_Li knows that politeness and respect come before the coding knowledge.
I have two examples of millions data points can prove than nmpy array is 10x faster than python list. But, both times are in microseconds.
Time taken for numpy array multiplication: 0.008976 seconds
Time taken for python list multiplication: 0.081783 seconds
However, I don't believe that this microsecond difference is worthy!
+ 1
`
import numpy as np
import time
# Using numpy arrays
a = np.random.rand(1000000)
b = np.random.rand(1000000)
start = time.time()
c = a * b
end = time.time()
print(f"Time taken for numpy array multiplication: {end-start:.6f} seconds")
# Using python lists
a = [np.random.rand() for _ in range(1000000)]
b = [np.random.rand() for _ in range(1000000)]
start = time.time()
c = [a[i] * b[i] for i in range(len(a))]
end = time.time()
print(f"Time taken for python list multiplication: {end-start:.6f} seconds")
`
+ 1
Abdulfattah Alhazmi even 10**(-10**999)ms matters a lot when comes to actual development
cause our world needs 1st class app + fast processing