• In performance-oriented computing, vectorisation means expressing an algorithm in terms of SIMD (vector) CPU instructions with the goal of using the parallelism that they offer to speed up the algorithm even within one CPU core. If the algorithm is well suited to such parallelisation (e.g. because it doesn’t really contain control flow and operates on a batch of data), this speedup can be expected to be 2-8x or even more depending on the width of the numbers involved, the hardware and how memory-bound the algorithm is.

      I have no clue on the conventional usage within the Python ecosystem (I don’t use Python outside some simple scripts), but I expect the link is that C compilers perform automatic vectorisation and the Python interpreter does not, and as such if you want vectorisation you have to move to a C extension. However, even without vectorisation compiled C will be faster than Python although I suppose the difference may be much smaller (or even nonexistent) when using a JIT compiler like PyPy.


      score 1 · canonical

      • You are on point. I would like to add that vectorize can also mean to work with lists/arrays like the mathematical concept of a vector. You can add vector A + the scalar B without needing to write a for-loop. np.vectorize is a good example of this, which let‘s you apply an arbitrary scalar function on to n-dimensional Numpy arrays. Performance optimization is not the goal here, but expressiveness.


        score 2 · canonical