Why Can I Not Replicate the NumPy v1.13.dev0 Manual Examples

前端 未结 1 1581
挽巷
挽巷 2021-01-26 10:32

As an example I am reading through the following:

https://docs.scipy.org/doc/numpy-dev/neps/new-iterator-ufunc.html

So I run a bit of code on my computer using i

相关标签:
1条回答
  • 2021-01-26 11:04

    Just to be clear the In[4] and [9] times are copied from that 6 yr old document. The [12][13] times are from your own tests (and basically the same as what I get). I haven't studied that old dev document, but have run the np.nditer examples on

    https://docs.scipy.org/doc/numpy/reference/arrays.nditer.html

    and know that nditer does not normally speed code. This iterator is meant to be used in C level code, and its exposure at the Python level is a convenience. It lets us test ideas in Python code before moving them to C or Cython. Note the Cython example at the end. Even so, I found I could get better speed in a simple multiplication case by using Cython memoryviews.

    np.ndindex is one of the few numpy functions that uses np.nditer in Python code. I've occasionally suggested a similar pattern to produce depth limited iteration.

    So don't worry too much about mastering np.nditer.

    0 讨论(0)
提交回复
热议问题