# Could \`reduce\_first\` avoid specializing on abstractly typed inputs?

**URL:** <https://discourse.julialang.org/t/could-reduce-first-avoid-specializing-on-abstractly-typed-inputs/142810>\
**Category:** Internals & Design\
**Created:** [November 8, 2026, 10:32am UTC](https://discourse.julialang.org/t/could-reduce-first-avoid-specializing-on-abstractly-typed-inputs/142810 "2026-11-08T10:32:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kimikage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kimikage/32/14534_2.png) [@kimikage](https://discourse.julialang.org/u/kimikage)\
**Post date:** [November 8, 2026, 10:32am UTC](https://discourse.julialang.org/t/could-reduce-first-avoid-specializing-on-abstractly-typed-inputs/142810/1 "2026-11-08T10:32:17Z")

</div>

Since the TTFX benchmark for CairoMakie.jl evaluates the impact of many packages, we (I) have added a relatively conservative TTFX benchmark for Colors.jl.

> **[Julia Performance Tracking](https://perf.julialang.org/?tab=bench-ttfx&tk=Colors%2FColor-Parsing-And-De2000-Comparison&tt=30)**
>
> Benchmarks, CI build timing, TTFX and PkgEval results for the Julia language.

This benchmark also highlights a known issue: the specialization of `reduce_first` in FixedPointNumbers.jl is causing invalidation.

Would it make sense for `Base` to use dynamic dispatch for `reduce_first` when the input type is abstract (e.g., `Any`), while retaining the current specialization behavior for concrete types?

I expect the performance impact to be limited. `reduce_first` is generally called only once, at the beginning of a reduction. Also, abstractly typed collections are generally avoided in performance-critical code.

Could this be a reasonable way to reduce invalidations caused by downstream packages adding more specific `reduce_first` methods?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [November 8, 2026, 11:10am UTC](https://discourse.julialang.org/t/could-reduce-first-avoid-specializing-on-abstractly-typed-inputs/142810/2 "2026-11-08T11:10:14Z")

</div>

> [@kimikage](#):
>
> Would it make sense for `Base` to use dynamic dispatch for `reduce_first` when the input type is abstract (e.g., `Any`), while retaining the current specialization behavior for concrete types?

Sounds great for me. These invalidations are really annoying.
