def commit(self):
        """
        Commit changes to disk if attached.

        This method helps normalize the interface for detached and
        attached tables and makes writing attached tables a bit more
        efficient. For detached tables nothing is done, as there is no
        notion of changes, but neither is an error raised (unlike with
        :meth:`write`). For attached tables, if all changes are new
        records, the changes are appended to the existing file, and
        otherwise the whole file is rewritten.
        """
        if not self.is_attached():
            return
        changes = self.list_changes()
        if changes:
            indices, records = zip(*changes)
            if min(indices) > self._last_synced_index:
                self.write(records, append=True)
            else:
                self.write(append=False)
Commit changes to disk if attached.

        This method helps normalize the interface for detached and
        attached tables and makes writing attached tables a bit more
        efficient. For detached tables nothing is done, as there is no
        notion of changes, but neither is an error raised (unlike with
        :meth:`write`). For attached tables, if all changes are new
        records, the changes are appended to the existing file, and
        otherwise the whole file is rewritten.