input: Write a function to optimize a Python program that processes a 2d array and stores the transpose output in a new array.
  
  def transpose(A):
   n = len(A)
   m = len(A[0])
  
   B = [[0 for x in range(n)] for x in range(m)]
  
   for i in range(n):
   for j in range(m):
   B[j][i] = A[i][j]
  
   return B
  
  assert transpose([[1,2,3],[4,5,6]])==[[1,4],[2,5],[3,6]]
  assert transpose([[1,2],[3,4],[5,6]])==[[1,3,5],[2,4,6]]
  assert transpose([[1]])==[[1]]
  assert transpose([[1],[2]])==[[1,2]]
  assert transpose([[],[],[]])==[]
output: def transpose(A):
      if not A or not A[0]:
          return []
      n = len(A)
      m = len(A[0])
      B = [[A[i][j] for i in range(n)] for j in range(m)]
      return B