input: Write a function to optimize the given Python program that processes a 2d array and stores the transpose output in a new array. If the input array is empty, 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([[7, 4], [2, 9], [1, 8]])==[[7, 2, 1], [4, 9, 8]]
  assert transpose([[5, 8, 3], [9, 2, 6]])==[[5, 9], [8, 2], [3, 6]]
  assert transpose([])==[]
  assert transpose([[1, 2]])==[[1], [2]]
output: def transpose(matrix):
      if not matrix:
          return []
      return [[matrix[j][i] for j in range(len(matrix))] for i in range(len(matrix[0]))]