## #006B Vectorization and Broadcasting in Python

**What is a Vectorization ?**

A vectorization is basically the art of getting rid of explicit for loops whenever possible. With the help of vectorization operations are applied to whole arrays instead of individual elements.

The rule of thumb to remember is to avoid using explicit for loops in your code.

Deep learning algorithms tend to shine when trained on large datasets, so it’s important that your code runs quickly. Otherwise, your code might take a long time to get your result.

For more informations about vectorization in NumPy click here.

**Broadcasting in Python**

The term broadcasting describes how NumPy treats arrays with different shapes during aritmetic operations. The simplest broadcasting example occurs when an array and a scalar value are combined in an operation. For example if we have matrix \(\textbf{A} \) and scalar value \(b \) then scalar b is being streched during the aritmetic operation into an array wich is the same shape as \(\textbf{A} \), but that stretch is only conceptual. Numpy uses the original scalar value without making copies, so that broadcasting operations are as memory and computationally efficient as possible. Let’s see some examples.

For more information about bradcasting in Python look here.