def _translate_slice(exp, length):
    """ Given a slice object, return a 3-tuple
        (start, count, step)
        for use with the hyperslab selection routines
    """
    start, stop, step = exp.indices(length)
    if step < 1:
        raise ValueError('Step must be >= 1 (got %d)' % step)
    if stop < start:
        return 0, 0, 1
    count = 1 + (stop - start - 1) // step
    return start, count, step
