Skip to content

PERF: Use optimized take path for non-nanosecond datetime64/timedelta64#65165

Open
jbrockmendel wants to merge 2 commits intopandas-dev:mainfrom
jbrockmendel:ref-special-2
Open

PERF: Use optimized take path for non-nanosecond datetime64/timedelta64#65165
jbrockmendel wants to merge 2 commits intopandas-dev:mainfrom
jbrockmendel:ref-special-2

Conversation

@jbrockmendel
Copy link
Copy Markdown
Member

@jbrockmendel jbrockmendel commented Apr 11, 2026

Summary

  • The take dispatch dictionaries only had entries for datetime64[ns] and timedelta64[ns]. Any other resolution fell through to the slow _take_nd_object fallback instead of the optimized Cython take_*_int64_int64 functions.
  • Fix _get_take_nd_function_cached and take_2d_multi to route dtype.kind in "mM" to the int64 wrapper for all resolutions.
  • Fix _view_wrapper fill value handling to use .view("i8") instead of hardcoding ns resolution (resolves existing FIXME).

~4.6x faster for 1d take, ~1.5x for 2d take on non-ns datetime64/timedelta64 arrays.

Test plan

  • New tests verify _get_take_nd_function_cached returns optimized function for non-ns resolutions (1d/2d, datetime64/timedelta64, us/ms/s)
  • New correctness tests for 1d and 2d take with fill on non-ns arrays
  • Existing take, datetimelike, indexing, and reindex tests all pass

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jbrockmendel jbrockmendel added the Performance Memory or execution speed performance label Apr 11, 2026
@jbrockmendel jbrockmendel marked this pull request as ready for review April 12, 2026 00:22
…ke.py

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant