Skip to content

Instantly share code, notes, and snippets.

@jasonaguilon-wf
Created July 11, 2014 14:55
Show Gist options
  • Select an option

  • Save jasonaguilon-wf/cf7109b60b87d49f934c to your computer and use it in GitHub Desktop.

Select an option

Save jasonaguilon-wf/cf7109b60b87d49f934c to your computer and use it in GitHub Desktop.
Comparing size of ndb repeated property with json property.
In [38]: ids = [uuid.uuid1().hex for n in range(20000)]
In [39]: class Foo(ndb.Model):
....: bar = ndb.TextProperty(compressed=True, repeated=True)
....: bazz = ndb.JsonProperty(compressed=True, json_type=list)
....:
In [40]: len(Foo(bar=ids)._to_pb().Encode())
Out[40]: 1218594
In [41]: len(Foo(bazz=ids)._to_pb().Encode())
Out[41]: 132491
@jasonaguilon-wf
Copy link
Author

@jasonaguilon-wf
Copy link
Author

btw, here's the db way:

from google.appengine.ext import db
sz_in_bytes = len(db.model_to_protobuf(some_entity).Encode())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment