import io
import gzip


def gzip_encode(content):
    """GZIP encode bytes object"""
    out = io.BytesIO()
    f = gzip.GzipFile(fileobj=out, mode='w', compresslevel=5)
    f.write(content)
    f.close()
    return out.getvalue()