def _rowsize(shape, maindim, itemsize):
    """"The size of the rows in bytes in dimensions orthogonal to *maindim*."

    shape:
        Shape of the sample to fit in the row

    maindim:
        The dimension along which iterators work. Its value is 0 (i.e. the first
        dimension) when the dataset is not extendable, and self.extdim (where
        available) for extendable ones.

    itemsize:
        nbytes of each element

    The meaning of *atomic* is that individual elements of a cell can not be
    extracted directly by indexing (i.e.  __getitem__()) the dataset; e.g. if a
    dataset has shape (2, 2) and its atoms have shape (3,), to get the third
    element of the cell at (1, 0) one should use dataset[1,0][2] instead of
    dataset[1,0,2].
    """
    rowsize = itemsize
    for i, dim in enumerate(shape):
        if i != maindim:
            rowsize *= dim
    return rowsize
