_uses_phys_key(term) re-runs an O(n²) phys_ops × phys_ops scan against ne on every isequal/hash (qterm.jl:28), and since QTerm is the dict key for every QAdd, this fires on every insertion and lookup.
Cache it as a uses_phys_key::Bool field set once in _term_key (after _canonical_ne) and read by isequal/hash. Tried briefly and reverted, re-attempt with a benchmark to confirm the win and that the extra field doesn't regress construction allocations.
_uses_phys_key(term)re-runs an O(n²)phys_ops × phys_opsscan againstneon everyisequal/hash(qterm.jl:28), and sinceQTermis the dict key for everyQAdd, this fires on every insertion and lookup.Cache it as a
uses_phys_key::Boolfield set once in_term_key(after_canonical_ne) and read byisequal/hash. Tried briefly and reverted, re-attempt with a benchmark to confirm the win and that the extra field doesn't regress construction allocations.