Skip to content

CLN: Use not .any() instead of comparing to 0 #57541

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 1 commit into from
Feb 21, 2024

Conversation

mroeschke
Copy link
Member

Follow up to #57534

In [1]: import numpy as np

In [2]: zeros = np.zeros(100_000)

In [4]: %timeit (zeros == 0).all()
36.4 µs ± 108 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)

In [5]: %timeit not np.all(zeros)
33.6 µs ± 111 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)

@mroeschke mroeschke added this to the 3.0 milestone Feb 20, 2024
@mroeschke mroeschke merged commit 2b568ce into pandas-dev:main Feb 21, 2024
@mroeschke mroeschke deleted the ref/any branch February 21, 2024 00:23
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant