Created
July 15, 2021 11:19
-
-
Save spider-man-tm/f616e4b31e2c503152d9aca569dd78be to your computer and use it in GitHub Desktop.
各変数のメモリ使用量を表示する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("{}{: >25}{}{: >10}{}".format('|', 'Variable Name', '|', 'Memory', '|')) | |
print(" ------------------------------------ ") | |
for var_name in dir(): | |
if not var_name.startswith("_") and sys.getsizeof(eval(var_name)) > 10000: | |
print("{}{: >25}{}{: >10}{}{: >5}{}".format( | |
'|', var_name, '|', sys.getsizeof(eval(var_name)), '|', sys.getrefcount(var_name), '|')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment