docs: def sync(self):
          '''Write the dict to disk'''
          if self.flag == 'r':
              return
          filename = self.filename
          tempname = filename + '.tmp'
          fileobj = open(tempname, 'wb' if self.file_format == 'pickle' else 'w')
          try:
              self.dump(fileobj)
          except Exception:
              os.remove(tempname)
              raise
          finally:
              fileobj.close()
          shutil.move(tempname, self.filename)    # atomic commit
          if self.mode is not None:
              os.chmod(self.filename, self.mode)