Ask Your Question

Revision history [back]

The reason for numpy's vectorize function to execute twice on the initial element is that it first runs the function with a small temporary input array containing the first element of the original input array. This is done to determine the output data type and shape. Once this is determined, the function is then executed on the entire input array, including the first element. Therefore, the function ends up being executed twice on the initial element.