astral-sh
ruff
BlogDocsChangelog

[ty] Remove redundant re-exports that share the same top-most module

#22581Merged
Comparing
ag/remove-redundant-auto-import-symbols
(
e092bd5
) with
main
(
aa9f1b2
)
CodSpeed Performance Gauge
0%
Untouched
23
Skipped
30

Benchmarks

Skipped (30)

Passed

sympy
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
0%
50.8 s50.7 s
tanjun
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
0%
2.5 s2.5 s
altair
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
0%
4.6 s4.6 s
hydra-zen
crates/ruff_benchmark/benches/ty.rs::project::hydra::project
CodSpeed Performance Gauge
0%
1.2 s1.2 s
DateType
crates/ruff_benchmark/benches/ty.rs::project::datetype::project
CodSpeed Performance Gauge
0%
236.6 ms236.7 ms
anyio
crates/ruff_benchmark/benches/ty.rs::project::anyio::project
CodSpeed Performance Gauge
0%
1.2 s1.2 s
attrs
crates/ruff_benchmark/benches/ty.rs::project::attrs::project
CodSpeed Performance Gauge
0%
434.3 ms434.6 ms
freqtrade
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
0%
8 s8 s
ty_check_file[cold]
crates/ruff_benchmark/benches/ty.rs::check_file::benchmark_cold
CodSpeed Performance Gauge
0%
130.6 ms130.8 ms
colour_science
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
0%
89.8 s90 s
ty_micro[many_enum_members_2]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_many_enum_members_2
CodSpeed Performance Gauge
0%
152.1 ms152.3 ms
ty_micro[complex_constrained_attributes_2]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_complex_constrained_attributes_2
CodSpeed Performance Gauge
0%
67.8 ms68 ms
ty_micro[complex_constrained_attributes_3]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_complex_constrained_attributes_3
CodSpeed Performance Gauge
0%
70.9 ms71 ms
ty_micro[many_tuple_assignments]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_many_tuple_assignments
CodSpeed Performance Gauge
0%
65.7 ms65.8 ms
ty_micro[many_tuple_assignments]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_tuple_implicit_instance_attributes
CodSpeed Performance Gauge
0%
67.7 ms67.8 ms
ty_micro[complex_constrained_attributes_1]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_complex_constrained_attributes_1
CodSpeed Performance Gauge
0%
67.8 ms67.9 ms
ty_micro[many_enum_members]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_many_enum_members
CodSpeed Performance Gauge
0%
122.5 ms122.7 ms
ty_micro[many_string_assignments]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_many_string_assignments
CodSpeed Performance Gauge
0%
77.3 ms77.4 ms
pydantic
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
0%
10.3 s10.4 s
multithreaded
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
0%
1.2 s1.2 s
ty_check_file[incremental]
crates/ruff_benchmark/benches/ty.rs::check_file::benchmark_incremental
CodSpeed Performance Gauge
0%
6.1 ms6.1 ms
pandas
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
0%
64.1 s64.4 s
static_frame
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
-1%
21.9 s22.1 s

Commits

Click on a commit to change the comparison range
Base
main
aa9f1b2
-0.17%
[ty] Remove redundant re-exports that share the same top-most module The implementation here is (to me) surprisingly complicated. The main complications are: 1. Trying to limit the redundant detection to as few of the symbols we extract as possible. In particular, while I haven't done benchmarking on this, I perceive the redundancy detection to be somewhat expensive and auto-import can return lots of symbols. So we're careful to only do this extra checking on (typically) small groups of symbols that could possibly be merged. 2. Even by restricting our work, this merging process could still be called quite a bit. (Thousands of times in my "standard data scienc-y test environment.") So I went out of my way to amortize allocs. 3. Re-exports can form a chain and we want to find all of them. 4. We (probably) don't want to remove redundant re-exports unless they share the same top-level module. Otherwise, e.g., a library that re-exports another library's symbols could have all of its re-exports dropped. 5. We want to only keep the top-most re-exports, and there may be multiple such re-exports. So we keep all of them. 6. We can't assume anything about the relationship of re-exports and the original definition. A re-export could be deeper in the module hierarchy than the original definition or above it.
e092bd5
23 hours ago
by BurntSushi
© 2026 CodSpeed Technology
Home Terms Privacy Docs