Skip to content
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

PERF: optimize Index.delete for dtype=object #7040

Merged
merged 1 commit into from
May 5, 2014

Conversation

immerrr
Copy link
Contributor

@immerrr immerrr commented May 5, 2014

This should close #6933.

The downside of this patch is that we'll lose type inference that might change index type in rare occasions when index items have different dtypes. This is the same issue that occurred in #6440, and it was ruled out as infrequent and worth dropping for extra performance.

Note though, that the benchmark results are not exactly what I've expected:

In [39]: idx = tm.makeStringIndex(100000)

In [40]: timeit idx.delete(-1)
1000 loops, best of 3: 1.46 ms per loop

In [41]: timeit np.delete(idx, -1)
1000 loops, best of 3: 1.05 ms per loop

The result is faster, but not as fast as I'd expect. This is probably because of object refcounting overhead, because MultiIndex fares a lot better with its Categorial-like implementation:

In [42]: midx = pd.MultiIndex.from_product([[0], idx])

# <..snip..>

In [45]: timeit midx.delete(-1)
1000 loops, best of 3: 225 µs per loop

@jreback jreback added Parallel and removed Parallel labels May 5, 2014
@jreback
Copy link
Contributor

jreback commented May 5, 2014

ok...looks fine...merge?

@jreback jreback added this to the 0.14.0 milestone May 5, 2014
@immerrr
Copy link
Contributor Author

immerrr commented May 5, 2014

Yeah, it's ready.

I wasn't sure about combining release notes, but they did seem relevant. If that's ok, let's merge it.

@jreback
Copy link
Contributor

jreback commented May 5, 2014

yeh...combing is fine when pretty related

jreback added a commit that referenced this pull request May 5, 2014
PERF: optimize Index.delete for dtype=object
@jreback jreback merged commit e54fbee into pandas-dev:master May 5, 2014
@immerrr immerrr deleted the perf-index-delete branch May 5, 2014 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PERF: use fastpath=True in Index methods (delete/drop/insert/etc)?
2 participants