Geek Culture
Published in

Geek Culture

5 Advanced Vectorisation Techniques for Improved Python Performance

Use NumPy to speed up your code.

Photo by Charlotte Coneybeer on Unsplash

NumPy vectorisation applies a function to an entire array in one call. For example:

a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
u = np.sqrt(a) # [1. 1.414 1.732]
v = a + b # [5 7 9]

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store