Monday, April 18, 2011

Size of objects in Python

struct.calcsize(fmt) - only gives size of fixed data types given by fmt
sys.getsizeof(obj) - (added in Python 2.7) gives the size in bytes of builtin types, but not the actual used memory
pympler.asizeof(obj) - gives the actual memory the object uses

No comments:

Post a Comment