code: def gzip_compress(data):
      
      buf = BytesIO()
      with gzip.GzipFile(fileobj=buf, mode='wb') as fd:
          fd.write(data)
      return buf.getvalue()
docs: Compress a string. Same as gzip.compress in Python3.