'This creates a subclass of the column\'s class which overrides that
class\'s ``__getitem__``, such that when returning a slice of the
column, the relevant indices are also copied over to the slice.
Ideally, rather than shimming in a new ``__class__`` we would be able
to just flip a flag that is checked by the base class\'s
``__getitem__``.  Unfortunately, since the flag needs to be a Python
variable, this slows down ``__getitem__`` too much in the more common
case where a copy of the indices is not needed.  See the docstring for
``astropy.table._column_mixins`` for more information on that.'

def _get_copy_on_getitem_shim(self, cls):

    if (cls in self._col_subclasses):
        return self._col_subclasses[cls]
    def __getitem__(self, item):
        value = cls.__getitem__(self, item)
        if (type(value) is type(self)):
            value = self.info.slice_indices(value, item, len(self))
        return value
    clsname = u'_{0}WithIndexCopy'.format(cls.__name__)
    new_cls = type(str(clsname), (cls,), {u'__getitem__': __getitem__})
    self._col_subclasses[cls] = new_cls
    return new_cls
