(C) Copyright 2023 Pavel Tisnovsky
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
Contributors: Pavel Tisnovsky
link to source: https://github.com/tisnik/most-popular-python-libs/blob/master/asizeof/asizeof08.py
link to source in literate programming format: https://tisnik.github.io/most-popular-python-libs/asizeof/asizeof08.html
from pympler import asizeof
def print_sizeof(value):
typename = "{:8}".format(type(value).__name__)
print(asizeof.asizeof(value), "\t", typename, "\t", value)
def foo():
pass
def bar(x, y):
return x + y
def baz(x=0, y=1):
print(x)
print(y)
return x + y
print_sizeof(print)
print_sizeof(foo)
print_sizeof(bar)
print_sizeof(baz)