From the course: Faster Python Code
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
NumPy
- [Instructor] If you're doing a lot of numerical computation, you should look into NumPy. And my guess is that you already have. At its heart, NumPy provide a matrix data type called an array and a set of mathematical functions. All of these are written in super-optimized C. NumPy is the base for most of python scientific stack. Packages such as Pandas, psychic learn and others heavily use NumPy under the hood. NumPy uses machine-level numbers. Which are different from Python numbers. Python numbers can grow as much as you want. Let's have a look. Ipython. Let's take two to the power of 1,000. This is really long number that doesn't fit in a machine integer. However, import NumPy as np. And then we'll do np.int64 of two to the power of 1,000. And we'll get zero. This is an overflow. In most practical cases this overflow is not a problem, but you should be aware of it. Remember to write test cases before you start…