Tools 1.1The video for this lesson is on its way.
Everything else is ready: study the parts, the key terms and the quiz below.
- Part 11Summing a list with a Python loop, and timing it
- Part 22Why NumPy, and array oriented computing
- Part 33References, objects and the packed buffer
- Part 44Creating an array with np.array, and summing it
- Part 55How the speed difference scales with array size
- Part 66Fixed width types, and object dtype
- Part 77Recap and your challenge
Tools 1.1Code walkthrough7 parts
Why NumPy
Say what an array holds that a list does not, and why that makes it faster and smaller.
Loading your progress…Next: 1.2 Shape, dtype and Reshaping
In this lesson7 parts
- 01Summing a list with a Python loop, and timing it
- 02Why NumPy, and array oriented computing
- 03References, objects and the packed buffer
- 04Creating an array with np.array, and summing it
- 05How the speed difference scales with array size
- 06Fixed width types, and object dtype
- 07Recap and your challenge
Quiz 5 questions
Answer each one in your head, or on paper, before you check it. Getting one wrong here is how the lesson sticks.
- 01
Three hundred and sixty five prices take
12016bytes as a Python list and2920bytes as a NumPy array. Where did the difference go? - 02
Why is the Python loop slower than
takings.sum()? - 03
What does
np.array([2 ** 70])produce? - 04
At a thousand values, you time three things: the Python loop,
arr.sum()on an array you already have, andnp.array(values).sum()starting from a list. Which is slowest? - 05
So when does converting a list to an array pay off?