diff --git a/docs/src/changelog.md b/docs/src/changelog.md index d608cfead..1213efe7b 100644 --- a/docs/src/changelog.md +++ b/docs/src/changelog.md @@ -31,6 +31,9 @@ When releasing a new version, move the "Unreleased" changes to a new version sec ### Performance +- Constructing an `MPOHamiltonian` from local operators compiles about twice as fast on + Julia 1.13 and 1.14. ([#554](https://github.com/QuantumKitHub/MPSKit.jl/pull/554)) + ## [0.14.1](https://github.com/QuantumKitHub/MPSKit.jl/compare/v0.14.0...v0.14.1) - 2026-11-02 ### Added diff --git a/src/operators/mpohamiltonian.jl b/src/operators/mpohamiltonian.jl index 4b724a4eb..c3f1c4b7d 100644 --- a/src/operators/mpohamiltonian.jl +++ b/src/operators/mpohamiltonian.jl @@ -513,9 +513,12 @@ of two proportional operators need not be related by that same scalar. """ function _instantiate_operators(lattice, local_operators) representatives = Tuple{Any, Any, Any}[] - return map(collect(local_operators)) do term - return instantiate_operator(lattice, _decompose_once!(representatives, term)) - end + # A comprehension rather than `map`: all of the work happens in here, and type inference + # limits `map` calls that are nested within another `map` (JuliaLang/julia#64862). + return [ + instantiate_operator(lattice, _decompose_once!(representatives, term)) + for term in collect(local_operators) + ] end # terms that are not supplied as an `inds => operator` pair -- e.g. a `LocalOperator` -- and