Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added object size in show most common type #60

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

gksalil
Copy link

@gksalil gksalil commented Mar 5, 2021

This commit will give object size too in the output

@gksalil gksalil closed this Mar 5, 2021
@gksalil gksalil reopened this Mar 5, 2021
Copy link
Owner

@mgedmin mgedmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

This is definitely an interesting idea, but I dislike how it makes backwards-incompatible changes to the structure of the return value. Perhaps a second function, typestats_with_sizes() would be better?

Also, I will not merge it without documentation changes.

@@ -273,7 +274,8 @@ def show_most_common_types(
filter=filter)
width = max(len(name) for name, count in stats)
for name, count in stats:
file.write('%-*s %i\n' % (width, name, count))
file.write('%-*s - %i - %i - %i\n' %
(width, name, count[0], count[1], count[0]*count[1]))
Copy link
Owner

@mgedmin mgedmin Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes all the objects of the same type are of the same size, which is not necessarily true.

On my laptop sys.getsizeof("a") == 50, but sys.getsizeof("a"*1000) == 1049.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants