Skip to content

perf-005: O(n²) inner loop in value_tns_slice #230

Description

@python-processing-unit

Problem

For each output element, both slice-read and slice-write paths linearly scan \orig_to_out[]\ to map output dim → input dim. This is O(output × ndim).

Location: \src/value.c:378-410, \src/interpreter.c:2973-3003\ (\�ssign_index_chain)

Proposed Fix

Precompute \out_to_orig[new_ndim]\ and fixed-dim offset once before the loop. Inner loop becomes O(1) per dim.

Status

Baseline still present — \src/value.c:386-393\ still scans \orig_to_out[]\ linearly inside the output element loop.

Metadata

Metadata

Labels

interpreterRequires a code change in the interpreter.patchRequires a patch version change.performancePerformance improvement.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions