I'm playing around with Python's and NumPy's methods to compare their performance:
import numpy as np
massive_array = np.random.random(100000)
%timeit sum(massive_array) # Python's sum()
%timeit np.sum(massive_array) # NumPy's np.sum()
Which works fine and returns the following:
9.56 ms ± 523 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
51.9 µs ± 1.59 µs per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
The only problem is that, while using the notebook on vscode, I get an error flagged by Pylance
regarding the percentage symbol for %timeit
:
What's the reason for it to be flagged? Shouldn't that be a valid expression, given that it also executed successfully?