🤖 Autoloop program issue for tsb-perf-evolve. The program definition below is mirrored from .autoloop/programs/tsb-perf-evolve/program.md. Edit the file to update the definition; comment on this issue to steer the agent.
tsb perf evolve — Series.sortValues vs pandas Series.sort_values
Goal
Evolve the implementation of Series.sortValues (src/core/series.ts) so that, on the synthetic benchmark in code/benchmark.ts, tsb runs at least as fast as pandas on the equivalent Series.sort_values call (code/benchmark.py).
Concretely, we minimize the ratio
fitness = mean_ms_tsb / mean_ms_pandas
fitness < 1.0 means tsb is faster than pandas; lower is better. We will keep iterating as long as fitness keeps improving.
This is a performance-evolution program — there is one self-contained artifact (Series.sortValues), one scalar fitness (the ratio), and many plausible algorithmic families to try (comparison sort, typed-array indirect sort, dtype-dispatched non-comparison sort, batched/SoA, etc.). It is the canonical case for the AlphaEvolve strategy.
Validity invariants
- The existing test suite for
sortValuespasses. - The function signature is unchanged:
sortValues(ascending = true, naPosition: "first" | "last" = "last"): Series<T>. - No new runtime dependencies.
- TypeScript strict mode satisfied.
- Behaviour identical to reference for all dtypes, both ascending/descending, both
naPositionvalues, and empty Series.
Target
Only modify: src/core/series.ts (sortValues method body) and .autoloop/programs/tsb-perf-evolve/code/**.
Evaluation
Metric: fitness = tsb_mean_ms / pandas_mean_ms. Lower is better. < 1.0 means tsb is faster than pandas.