'Return a copy of the current Query. A lightweight alternative to
to deepcopy().'

def clone(self):

    obj = Empty()
    obj.__class__ = self.__class__
    obj.__dict__ = self.__dict__.copy()
    obj.alias_refcount = self.alias_refcount.copy()
    obj.alias_map = self.alias_map.copy()
    obj.external_aliases = self.external_aliases.copy()
    obj.table_map = self.table_map.copy()
    obj.where = self.where.clone()
    obj._annotations = (self._annotations.copy() if (self._annotations is not None) else None)
    if (self.annotation_select_mask is None):
        obj.annotation_select_mask = None
    else:
        obj.annotation_select_mask = self.annotation_select_mask.copy()
    obj._annotation_select_cache = None
    obj._extra = (self._extra.copy() if (self._extra is not None) else None)
    if (self.extra_select_mask is None):
        obj.extra_select_mask = None
    else:
        obj.extra_select_mask = self.extra_select_mask.copy()
    if (self._extra_select_cache is None):
        obj._extra_select_cache = None
    else:
        obj._extra_select_cache = self._extra_select_cache.copy()
    if ('subq_aliases' in self.__dict__):
        obj.subq_aliases = self.subq_aliases.copy()
    obj.used_aliases = self.used_aliases.copy()
    with suppress(AttributeError):
        del obj.base_table
    return obj
