Skip to content
Discussion options

You must be logged in to vote

sys.getsizeof is not implemented in MicroPython. Internally, the heap does know the allocated size of a given object, but many objects have multiple layers of allocations (e.g. a dictionary object contains a pointer to its table, which contains pointers to keys and values, etc).

getsizeof works in CPython with runtime support - builtin types must implement this to report their size. This would add a lot of code size, so is unlikely to ever be included in standard MicroPython firmware.

If your goal is to understand how much RAM different representations take up, then using gc.mem_alloc() to compute a difference might be more useful.

def make_timetable():
  ...
  return obj

def compute_all…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@gnbl
Comment options

@jimmo
Comment options

Answer selected by gnbl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants