Skip to content

PERF: avoid warnings in IndexEngine.get_loc #43792

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
Sep 29, 2021

Conversation

jbrockmendel
Copy link
Member

Only reached for non-unique indexes. Makes a big difference for small indexes.

Room for de-duplication in follow-ups.

import numpy as np
import pandas as pd

np.random.seed(90)
arr = np.random.randn(4).repeat(2)
idx = pd.Index(arr)
assert not idx.is_unique
key = arr[4]
engine = idx._engine

%timeit engine.get_loc(key)
6.6 µs ± 50.6 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)  # <- master
2.62 µs ± 127 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)  # <- PR

@jbrockmendel jbrockmendel added the Performance Memory or execution speed performance label Sep 29, 2021
@jreback jreback added this to the 1.4 milestone Sep 29, 2021
@jreback jreback merged commit e27ef39 into pandas-dev:master Sep 29, 2021
@jbrockmendel jbrockmendel deleted the ref-check_type branch September 29, 2021 16:39
gasparitiago pushed a commit to gasparitiago/pandas that referenced this pull request Oct 9, 2021
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.

2 participants