Skip to content

Conversation

@ANtutov
Copy link

@ANtutov ANtutov commented Nov 22, 2025

This change reduces redundant work in SparseTerm hot paths without altering semantics. In partial_cmp, computing degree() for both sides once and reusing the results avoids repeated summations during term sorting invoked by SparsePolynomial::from_coefficients_vec, which can be significant for large term lists. In is_constant, an early return when the term is empty eliminates unnecessary degree aggregation for the common constant case, while retaining a fallback degree() == 0 check to remain correct for terms constructed without normalization, such as SparseTerm(vec![(i, 0)]), which are present in tests.

@ANtutov ANtutov requested review from a team as code owners November 22, 2025 22:21
@ANtutov ANtutov requested review from Pratyush, mmagician and z-tech and removed request for a team November 22, 2025 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant