Page 1 of 1

size of object

Posted: Sun Mar 10, 2019 12:59 am
by philwilkinson40
Is there an equivalent of sys.getsizeof() in micropython?

I am looking to check the size of various objects prior to sending data across a LPWAN from a remote IOT device. If the size is too large I may split the data or save to a local SD card.

If this is not implemented, is there a way I can obtain the size at a point where I ustruct.pack() ??

sorry for the basic python primitives question... :oops:

Re: size of object

Posted: Sun Mar 10, 2019 1:13 am
by dhylands
You can use struct.calcsize(fmt) to determine how much data will be needed to store a given fmt string. This is the same fmt string that is passed to struct.pack