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

Use more, cheaper dtype checking utilities in cudf Python #18139

Open
wants to merge 1 commit into
base: branch-25.04
Choose a base branch
from

Conversation

mroeschke
Copy link
Contributor

Description

Avoids using potentially more expensive dtype checking utilities referenced in #12494

is_string_dtype -> == CUDF_STRING_DTYPE
is_decimal_dtype -> isinstance
is_numeric_dtype -> (new) is_dtype_obj_numeric

In [1]: import numpy as np

In [2]: from cudf.api.types import is_numeric_dtype

In [3]: from cudf.utils.dtypes import is_dtype_obj_numeric

In [4]: dtype = np.dtype(np.int64)

In [5]: %timeit is_dtype_obj_numeric(dtype)
211 ns ± 2.26 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

In [6]: %timeit is_numeric_dtype(dtype)
1.14 μs ± 2.61 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

Also standardizes some imports from cudf.api.types

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@mroeschke mroeschke added Python Affects Python cuDF API. improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Feb 28, 2025
@mroeschke mroeschke self-assigned this Feb 28, 2025
@mroeschke mroeschke requested a review from a team as a code owner February 28, 2025 23:45
@mroeschke mroeschke requested review from bdice and Matt711 February 28, 2025 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant