(o)
| 483 | default_size = getsizeof(0) class="cm"># estimate sizeof object without __sizeof__ |
| 484 | |
| 485 | def sizeof(o): |
| 486 | if id(o) in seen: class="cm"># do not double count the same object |
| 487 | return 0 |
| 488 | seen.add(id(o)) |
| 489 | s = getsizeof(o, default_size) |
| 490 | |
| 491 | for typ, handler in all_handlers.items(): |
| 492 | if isinstance(o, typ): |
| 493 | s += sum(map(sizeof, handler(o))) |
| 494 | break |
| 495 | return s |
| 496 | |
| 497 | return sizeof(o) |
| 498 |
no test coverage detected