input: Write a function to optimize the processing of a 2d array such that the transpose of the array is stored in a new array. The function should be able to handle any rectangular 2d array.
  
  def transpose(A):
      n = len(A)
      m = len(A[0])
      
      B = [[A[i][j] for i in range(n)] for j in range(m)]
      
      return B
  
  assert transpose([[1, 2, 3], [4, 5, 6]]) == [[1, 4], [2, 5], [3, 6]]
  assert transpose([[1], [2], [3]]) == [[1, 2, 3]]
  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([[]]) == []
output: def transpose(A):
      n = len(A)
      m = len(A[0]) if A else 0
      
      B = [[A[i][j] for i in range(n)] for j in range(m)]
      
      return B