-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PERF: use isinstance(obj, Foo) instead of ABCFoo #34040
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: use isinstance(obj, Foo) instead of ABCFoo #34040
Conversation
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.
Thanks @jbrockmendel lgtm ex use of aliases
pandas/core/frame.py
Outdated
@@ -7020,8 +7014,8 @@ def _gotitem( | |||
self, | |||
key: Union[str, List[str]], | |||
ndim: int, | |||
subset: Optional[Union[Series, ABCDataFrame]] = None, | |||
) -> Union[Series, ABCDataFrame]: | |||
subset: Optional[Union[Series, "DataFrame"]] = None, |
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.
_typing.FrameOrSeriesUnion or _typing.FrameOrSeries?
pandas/core/frame.py
Outdated
subset: Optional[Union[Series, ABCDataFrame]] = None, | ||
) -> Union[Series, ABCDataFrame]: | ||
subset: Optional[Union[Series, "DataFrame"]] = None, | ||
) -> Union[Series, "DataFrame"]: |
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.
same
Thanks! |
per discussion in #27353, isinstance checks with the ABCFoo are about 4x as expensive as the Foo checks. Individually they are still very small, but they add up.