Skip to content

PERF: fast-path empty delete indices#31895

Draft
KRRT7 wants to merge 2 commits into
numpy:mainfrom
KRRT7:delete-empty-fastpath
Draft

PERF: fast-path empty delete indices#31895
KRRT7 wants to merge 2 commits into
numpy:mainfrom
KRRT7:delete-empty-fastpath

Conversation

@KRRT7

@KRRT7 KRRT7 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

PR summary

Add a fast path for np.delete when given an empty integer indexer. The result is still a copy, matching the existing delete contract, but avoids allocating and applying a full boolean keep mask.

ASV quick comparison against main:

bench_function_base.Delete.time_empty_indices((100, 100), None): 29.0 us -> 24.6 us
bench_function_base.Delete.time_empty_indices((100, 100), 0):    34.6 us -> 28.5 us
bench_function_base.Delete.time_empty_indices((1000,), 0):       29.8 us -> 20.5 us
bench_function_base.Delete.time_empty_indices((1000,), None):    45.0 us -> 31.3 us

First time committer introduction

I am a NumPy user/contributor looking at small, focused performance improvements in common array operations. I will handle review discussion and follow-up changes directly.

AI Disclosure

LLM / Harness: hybrid.

AI assistance was used to inspect the codebase, run local commands and benchmarks, draft PR text, and help prepare candidate patches. I reviewed the generated suggestions, selected the final changes, and am responsible for the code, submission, and follow-up discussion. Some PR text and candidate code edits were drafted with AI assistance; the final patch and text were reviewed and edited by me.

@Aniketsy

Aniketsy commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

just a suggestion, please don't ignore PR template (in your other PR too)

You ignored the PR template, so I'm going to assume that this PR has been made with agentic AI. This violates our AI policy; we prefer to talk to humans.

as Joren previously suggested

@KRRT7 KRRT7 marked this pull request as draft July 7, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants