Skip to content

PERF: use python int in RangeIndex.get_loc #26697

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
Jun 7, 2019

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Jun 6, 2019

Follow-up to #26565. I didn't ensure a python int in RangeIndex.get_loc in the original PR, causing a slow performance when using a key with a wrong type:

In [1]: rng =  pd.RangeIndex(1_000_000)
In [2]: %timeit rng.get_loc(np.int64(900_000))
156 ms ± 1.03 ms per loop  # master
478 ns ± 6.3 ns per loop # this PR

Also some cleanups in __getitem__.

@codecov
Copy link

codecov bot commented Jun 6, 2019

Codecov Report

Merging #26697 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26697      +/-   ##
==========================================
- Coverage   91.88%   91.88%   -0.01%     
==========================================
  Files         174      174              
  Lines       50701    50699       -2     
==========================================
- Hits        46588    46583       -5     
- Misses       4113     4116       +3
Flag Coverage Δ
#multiple 90.41% <100%> (ø) ⬆️
#single 41.93% <100%> (-0.09%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/range.py 98.81% <100%> (+0.28%) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 97% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 649ad5c...cfbafe9. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Jun 6, 2019

Codecov Report

Merging #26697 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26697      +/-   ##
==========================================
- Coverage   91.88%   91.88%   -0.01%     
==========================================
  Files         174      174              
  Lines       50701    50699       -2     
==========================================
- Hits        46588    46583       -5     
- Misses       4113     4116       +3
Flag Coverage Δ
#multiple 90.41% <100%> (ø) ⬆️
#single 41.93% <100%> (-0.09%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/range.py 98.81% <100%> (+0.28%) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 97% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 649ad5c...cfbafe9. Read the comment docs.

@topper-123 topper-123 added Index Related to the Index class or subclasses Performance Memory or execution speed performance labels Jun 7, 2019
@topper-123 topper-123 added this to the 0.25.0 milestone Jun 7, 2019
@jreback jreback merged commit 5b10e31 into pandas-dev:master Jun 7, 2019
@jreback
Copy link
Contributor

jreback commented Jun 7, 2019

thanks @topper-123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Index Related to the Index class or subclasses Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants