Skip to content

Return early from isless for equal product sectors - #116

Merged
leburgel merged 1 commit into
mainfrom
lb/productsector_isless_equal
Oct 21, 2026
Merged

leburgel merged 1 commit into
mainfrom
lb/productsector_isless_equal

Conversation

@leburgel

Copy link
Copy Markdown
Member

isless on ProductSectors computes the index of every factor of both sectors, also when they are equal, which is the common case when sorting tuples of sectors. Checking isequal first makes that 2–4× cheaper; different sectors are unaffected.

isless(a, a) before after
FermionParity ⊠ U1Irrep ⊠ SU2Irrep ⊠ U1Irrep 10 ns 5 ns
FermionParity ⊠ U1Irrep ⊠ SU3Irrep 19–21 ns 5 ns
Reproducer
using TensorKitSectors, BenchmarkTools
a = FermionParity(1) ⊠ U1Irrep(1) ⊠ SU2Irrep(1 // 2) ⊠ U1Irrep(1)
b = FermionParity(0) ⊠ U1Irrep(-2) ⊠ SU2Irrep(1) ⊠ U1Irrep(3)
@btime isless($a, $a)
@btime isless($a, $b)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/product.jl 94.52% <100.00%> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leburgel
leburgel merged commit 147b25f into main Oct 21, 2026
12 checks passed
@leburgel
leburgel deleted the lb/productsector_isless_equal branch October 21, 2026 08:30
@leburgel leburgel mentioned this pull request Oct 22, 2026
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.

2 participants