forked from NVIDIA/spark-rapids
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove _getattr_ method in RangeIndex class (NVIDIA#10538)
This PR helps reduce implicit conversions by minimizing unnecessary `Int64Index `column materialization by the RangeIndex class( PR rapidsai/cudf#9593). Replaces rapidsai/cudf#10388. The following methods have been explicitly implemented for RangeIndex in this PR : `_column, _columns, where, isna, argsort, max, min, nunique, values_host, to_numpy, to_arrow, __array__ ` ### As demonstrated by the results posted in this[ comment](rapidsai/cudf#10538 (comment)), **on average:** - There's an evident performance gain with the new implementations of `values_host, to_numpy, nunique, min and max ` - `isna` and `argsort` demonstrate inconsistent measurements of performance perhaps due to memory allocation discrepancies - Whereas` to_arrow` and `where` still materialize an `Int64Index` Authors: - Sheilah Kirui (https://github.com/skirui-source) - Vyas Ramasubramani (https://github.com/vyasr) - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - GALI PREM SAGAR (https://github.com/galipremsagar) URL: rapidsai/cudf#10538
- Loading branch information
1 parent
c1d4a5e
commit 4528d8e
Showing
4 changed files
with
174 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) 2022, NVIDIA CORPORATION. | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.pandas_incompatible | ||
def bench_values_host(benchmark, rangeindex): | ||
benchmark(lambda: rangeindex.values_host) | ||
|
||
|
||
def bench_to_numpy(benchmark, rangeindex): | ||
benchmark(rangeindex.to_numpy) | ||
|
||
|
||
@pytest.mark.pandas_incompatible | ||
def bench_to_arrow(benchmark, rangeindex): | ||
benchmark(rangeindex.to_arrow) | ||
|
||
|
||
def bench_argsort(benchmark, rangeindex): | ||
benchmark(rangeindex.argsort) | ||
|
||
|
||
def bench_nunique(benchmark, rangeindex): | ||
benchmark(rangeindex.nunique) | ||
|
||
|
||
def bench_isna(benchmark, rangeindex): | ||
benchmark(rangeindex.isna) | ||
|
||
|
||
def bench_max(benchmark, rangeindex): | ||
benchmark(rangeindex.max) | ||
|
||
|
||
def bench_min(benchmark, rangeindex): | ||
benchmark(rangeindex.min) | ||
|
||
|
||
def bench_where(benchmark, rangeindex): | ||
cond = rangeindex % 2 == 0 | ||
benchmark(rangeindex.where, cond, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters