Skip to content

PERF: IntegerIndex._shallow_copy (and by extension, indexing) #32130

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 22, 2020

Conversation

jbrockmendel
Copy link
Member

In [2]: idx = pd.Index(range(1000)).insert(-1, 1)                                                                                                                                                                                                 
In [3]: %timeit idx[:5]                                                                                                                                                                                                                           
2.84 µs ± 97.6 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)  # <-- PR
24.5 µs ± 292 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)  # <-- master

In [4]: idx2 = idx.astype('uint64')                                                                                                                                                                                                               
In [5]: %timeit idx2[5:]                                                                                                                                                                                                                          
2.99 µs ± 331 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)  # <-- PR
25.8 µs ± 957 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)  # <-- master

Motivated by profiling in #32086 and seeing that _shallow_copy_with_infer was taking over a third of the runtime in the relevant benchmark.

@jbrockmendel jbrockmendel added the Performance Memory or execution speed performance label Feb 22, 2020
@jreback jreback added this to the 1.1 milestone Feb 22, 2020
@jreback
Copy link
Contributor

jreback commented Feb 22, 2020

likely we don't have these benchmarks directly, maybe add if you can.

@jreback jreback merged commit a66e149 into pandas-dev:master Feb 22, 2020
@jbrockmendel jbrockmendel deleted the fastpaths branch February 22, 2020 16:40
roberthdevries pushed a commit to roberthdevries/pandas that referenced this pull request Mar 2, 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.

2 participants