mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
![]() In *some* places in our crates, `serde` (and `rkyv`) are optional dependencies. I believe this was done out of reasons of "good sense," that is, it follows a Rust ecosystem pattern where serde integration tends to be an opt-in crate feature. (And similarly for `rkyv`.) However, ultimately, `uv` itself requires `serde` and `rkyv` to function. Since our crates are strictly internal, there are limited consumers for our crates without `serde` (and `rkyv`) enabled. I think one possibility is that optional `serde` (and `rkyv`) integration means that someone can do this: cargo test -p pep440_rs And this will run tests _without_ `serde` or `rkyv` enabled. That in turn could lead to faster iteration time by reducing compile times. But, I'm not sure this is worth supporting. The iterative compilation times of individual crates are probably fast enough in debug mode, even with `serde` and `rkyv` enabled. Namely, `serde` and `rkyv` themselves shouldn't need to be re-compiled in most cases. On `main`: ``` from-scratch: `cargo test -p pep440_rs --lib` 0.685 incremental: `cargo test -p pep440_rs --lib` 0.278s from-scratch: `cargo test -p pep440_rs --features serde,rkyv --lib` 3.948s incremental: `cargo test -p pep440_rs --features serde,rkyv --lib` 0.321s ``` So while a from-scratch build does take significantly longer, an incremental build is about the same. The benefit of doing this change is two-fold: 1. It brings out crates into alignment with "reality." In particular, some crates were _implicitly_ relying on `serde` being enabled without explicitly declaring it. This technically means that our `Cargo.toml`s were wrong in some cases, but it is hard to observe it because of feature unification in a Cargo workspace. 2. We no longer need to deal with the cognitive burden of writing `#[cfg_attr(feature = "serde", ...)]` everywhere. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |