input: Write a function to optimize a Python program that processes a 2D array and stores the transpose output in a new 2D array. The function should return the transposed array. If the input array is empty, the function should return an empty list.
  assert transpose([[1, 2, 3], [4, 5, 6], [7, 8, 9]])==[[1, 4, 7], [2, 5, 8], [3, 6, 9]]
  assert transpose([[1, 2], [3, 4]])==[[1, 3], [2, 4]]
  assert transpose([[1]])==[[1]]
  assert transpose([])==[]
output: def transpose(arr):
      if not arr:
          return []
      return [[arr[j][i] for j in range(len(arr))] for i in range(len(arr[0]))]