I need to compute the sizes of some python objects, so I can break them up and store them in memcache without hitting size limits.
'sizeof()' doesn't seem to be present on python objects in the GAE environment and sys.getsizeof() is also unavailable.
GAE itself is clearly checking sizes behind the scenes to enforce the limits. Any ideas for how to accomplish this? Thanks.
memcache
internally and invariably usespickle
and stores the resulting string, so you can check withlen(pickle.dumps(yourobject, -1))
. Note that sys.getsizeof (which requires 2.6 or better, which is why it's missing on GAE) would not really help you at all:since the size of a serialized pickle of the object can be quite different from the size of the object in memory, as you can see (so I guess you should feel grateful to GAE for not offering sizeof, which would have led you astray;-).