Skip to content

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

Merged
merged 10 commits into from
May 9, 2020

Conversation

jbrockmendel
Copy link
Member

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.

@simonjayhawkins simonjayhawkins added the Performance Memory or execution speed performance label May 8, 2020
Copy link
Member

@simonjayhawkins simonjayhawkins left a 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

@@ -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,
Copy link
Member

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?

subset: Optional[Union[Series, ABCDataFrame]] = None,
) -> Union[Series, ABCDataFrame]:
subset: Optional[Union[Series, "DataFrame"]] = None,
) -> Union[Series, "DataFrame"]:
Copy link
Member

Choose a reason for hiding this comment

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

same

@simonjayhawkins simonjayhawkins added this to the 1.1 milestone May 8, 2020
@jorisvandenbossche jorisvandenbossche merged commit e0eafaa into pandas-dev:master May 9, 2020
@jorisvandenbossche
Copy link
Member

Thanks!

@jbrockmendel jbrockmendel deleted the perf-abc-frame branch May 9, 2020 19:31
rhshadrach pushed a commit to rhshadrach/pandas that referenced this pull request May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants