-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PERF: faster dir() calls #37450
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
PERF: faster dir() calls #37450
Conversation
c0c3a97
to
0d38f73
Compare
pandas/core/generic.py
Outdated
for c in self._info_axis.unique(level=0)[:100] | ||
if isinstance(c, str) and c.isidentifier() | ||
} | ||
additions = self._info_axis._dir_additions_for_owner |
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.
instead of adding all of this code, why can't you slap a cache_readonly
here?
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.
That's not possible, because the axes (index/columns) can be changed. However, the axis labels are immutable, so it's safe to use cache_readonly
there.
I've changed the PR to avoid the addition in child classes.
94edc9f
to
5dd7294
Compare
53d0ce2
to
3a3b674
Compare
thanks @topper-123 |
I experience slow tab-completion in iPython, so I've optimized
dir
calls in pandas, e.g.It does this by caching the output for the info axis, when the info axis may have string, and returning an empty set for info axes that cannot have strings (numeric indexes etc.)
The above didn't actually improve the subjective speed of tab completion for me, so the problem there probably is in Ipython, but the change in this PR can't hurt either.