title: Using Pako deflate with Python
body: <p>I'm trying to compress a dictionary for accessing an API.<br>
  I read the code of someone compressing the data with JavaScript and a library called "pako" and tried it myself. It works perfectly:</p>
  
  <pre><code>var myDictionary = {...}
  
  var b = pako.deflate(JSON.stringify(a), { 
      to: "string", 
      gzip: !0 
    }); 
    return b = btoa(b) 
  }
  
  var compressed = b(n)
  </code></pre>
  
  <p>Now I would like to do the same with Python:
  I tried the following, but the result is different and doesn't work:</p>
  
  <pre><code>my_dictionary = {...}
  data_json = json.dumps(my_dictionary, ensure_ascii=False)
  data_gzip = zlib.compress(bytes(data_json, "utf-8"))
  compressed = base64.b64encode(bytes(str(data_gzip), "utf-8"))
  </code></pre>
  
  <p>Has anyone an ideal how to solve this problem with Python? Is there a similar library to pako for Python?</p>