-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PERF: unnecessary materialization of a MultiIndex.values when introspecting memory_usage #14308
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
Conversation
d018eb8
to
c47e0ba
Compare
# we are overwriting our base class to avoid | ||
# computing .values here which could materialize | ||
# a tuple representation uncessarily | ||
return self.nbytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we still need to recurse into the levels to get an accurate total if deep=True
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already done in .nbytes
(see a little below).
it actually ONLY does deep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, actually it *doesn't do deep....let me see if I can fix that too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is true.
Looking into the index base class, we compute the size of objects in memory_usage
:
https://github.com/pydata/pandas/blob/37f95cef85834207db0930e863341efb285e38a2/pandas/core/base.py#L1040
but not in nbytes
:
https://github.com/pydata/pandas/blob/37f95cef85834207db0930e863341efb285e38a2/pandas/core/base.py#L848
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sounds good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Current coverage is 85.26% (diff: 100%)@@ master #14308 diff @@
==========================================
Files 140 140
Lines 50614 50619 +5
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43155 43161 +6
+ Misses 7459 7458 -1
Partials 0 0
|
…ecting memory closes pandas-dev#14308
with this PR