Skip to content

PERF: is_list_like #39852

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 8 commits into from
Feb 17, 2021
Merged

PERF: is_list_like #39852

merged 8 commits into from
Feb 17, 2021

Conversation

jbrockmendel
Copy link
Member

In [3]: arr = np.array(0)
In [4]: arr2 = np.array([0])

In [5]: %timeit is_list_like([])
118 ns ± 2.21 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)   # <-- PR
328 ns ± 3.3 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)   # <-- master

In [6]: %timeit is_list_like(0)
271 ns ± 5.65 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)   # <-- PR
348 ns ± 4.17 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)   # <-- master

In [7]: %timeit is_list_like(arr)
111 ns ± 1.71 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)   # <-- PR
369 ns ± 24.4 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)  # <-- master

In [8]: %timeit is_list_like(arr2)
109 ns ± 3.39 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)   # <-- PR
340 ns ± 1.91 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)  # <-- master

@jreback jreback added the Performance Memory or execution speed performance label Feb 16, 2021
@jreback jreback added this to the 1.3 milestone Feb 16, 2021
@jreback
Copy link
Contributor

jreback commented Feb 16, 2021

nice! ping on green-ish.

from pandas import (
NA,
NaT,
)
Copy link
Member Author

Choose a reason for hiding this comment

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

@MarcoGorelli when the pre-commit hook runs locally, it resets these to single-line imports, which then fails the CI check. thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

@jbrockmendel have you already merged the latest upstream changes? If not, it might be because your setup.cfg file didn't have force_grid_wrap=True yet?

Copy link
Member Author

Choose a reason for hiding this comment

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

that did it, thanks

@jbrockmendel
Copy link
Member Author

ping

@jreback jreback merged commit 93d46cf into pandas-dev:master Feb 17, 2021
@jreback
Copy link
Contributor

jreback commented Feb 17, 2021

nice!

@jbrockmendel jbrockmendel deleted the perf-block-init branch February 17, 2021 21:01
aiudirog added a commit to aiudirog/pandas that referenced this pull request Sep 2, 2021
is_list_like() used to use isinstance(obj, abc.Iterable) before pandas-dev#39852 where it was optimized for performance. This resulted in a regression where objects that explicitly declare __iter__ as None are considered "list like" but not instances of abc.Iterable.
aiudirog added a commit to aiudirog/pandas that referenced this pull request Sep 2, 2021
is_list_like() used to use isinstance(obj, abc.Iterable) before pandas-dev#39852 where it was optimized for performance. This resulted in a regression where objects that explicitly declare __iter__ as None are considered "list like" but not instances of abc.Iterable.
aiudirog added a commit to aiudirog/pandas that referenced this pull request Sep 2, 2021
is_list_like() used to use isinstance(obj, abc.Iterable) before pandas-dev#39852 where it was optimized for performance. This resulted in a regression where objects that explicitly declare __iter__ as None are considered "list like" but not instances of abc.Iterable.
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