title: Most efficient way to map function over numpy array
body: <p>What is the most efficient way to map a function over a numpy array? I am currently doing:</p>
  <pre><code>import numpy as np 
  
  x = np.array([1, 2, 3, 4, 5])
  
  # Obtain array of square of each element in x
  squarer = lambda t: t ** 2
  squares = np.array([squarer(xi) for xi in x])
  </code></pre>
  <p>However, this is probably very inefficient, since I am using a list comprehension to construct the new array as a Python list before converting it back to a numpy array. Can we do better?</p>