From b9a0ccf01010d42575745c41d873b2e0219b60c4 Mon Sep 17 00:00:00 2001 From: Matthew Fishman Date: Thu, 10 Sep 2026 19:19:56 -0400 Subject: [PATCH] Avoid allocating a String when hashing a lazy tensor Symbol has no method taking a type, so Symbol(typename(T).wrapper) fell back to rendering the type through an IOBuffer on every call. nameof gives the same discriminator as a Symbol for free. Co-Authored-By: Claude Opus 5 (1M context) --- src/lazyitensors/lazyinterface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lazyitensors/lazyinterface.jl b/src/lazyitensors/lazyinterface.jl index a76ca0fc..057e859b 100644 --- a/src/lazyitensors/lazyinterface.jl +++ b/src/lazyitensors/lazyinterface.jl @@ -117,7 +117,7 @@ function isequal_lazy(a1, a2) end end function hash_lazy(a, h::UInt64) - h = hash(Symbol(Base.typename(typeof(a)).wrapper), h) + h = hash(nameof(typeof(a)), h) # Use `_hash`, which defines a custom hash for NamedTensor. return _hash(unwrap(a), h) end