def compute_item_matrix(items, row_first=False, empty=None, *args, **kwargs):
 info = _find_optimal(list(map(len, items)), row_first, *args, **kwargs)
 (nrow, ncol) = (info['max_rows'], info['num_columns'])
 if row_first:
  return ([[_get_or_default(items, ((r * ncol) + c), default=empty) for c in range(ncol)] for r in range(nrow)], info)
 else:
  return ([[_get_or_default(items, ((c * nrow) + r), default=empty) for c in range(ncol)] for r in range(nrow)], info)

def compute_item_matrix ( items , row_first = False , empty = None , * args , ** kwargs ) : info = _find_optimal ( list ( map ( len , items ) ) , row_first , * args , ** kwargs ) ( nrow , ncol ) = ( info [ 'max_rows' ] , info [ 'num_columns' ] ) if row_first : return ( [ [ _get_or_default ( items , ( ( r * ncol ) + c ) , default = empty ) for c in range ( ncol ) ] for r in range ( nrow ) ] , info ) else : return ( [ [ _get_or_default ( items , ( ( c * nrow ) + r ) , default = empty ) for c in range ( ncol ) ] for r in range ( nrow ) ] , info )
returns a nested list .