From 10f591e06e93eb852fca233247bcbec38283a2fc Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Thu, 26 Feb 2026 11:10:52 -0500 Subject: [PATCH] Remove redundant any/all methods on ArrayPartition to reduce invalidations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The custom `any(f::Function, A::ArrayPartition)` and `all(f::Function, ...)` methods caused 585 method invalidations when loading OrdinaryDiffEq, including invalidating critical Compiler internals (531 children from `any(::Compiler.compileable_specialization_check, ::AbstractArray)`). The `f::Function` specializations were redundant since the generic `f` versions already existed, but they conflicted with Base's `any(f::Function, a::AbstractArray; dims)`. The generic `f` versions also caused invalidations for the same reason — any new method on `any` for an `AbstractArray` subtype will invalidate cached `any(f, ::AbstractArray)` specializations. Since `ArrayPartition` implements proper iteration (via `eachindex` and `getindex`), the default `AbstractArray` implementations of `any` and `all` work correctly. Removing the custom methods eliminates the invalidation source with no behavioral change. Verified: `any(x->x>4, A)`, `all(x->x>0, A)`, `any(iszero, A)`, `any(A)` etc. all produce correct results via the default AbstractArray path. Co-Authored-By: Chris Rackauckas --- src/array_partition.jl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/array_partition.jl b/src/array_partition.jl index ffaadb89..89a39d38 100644 --- a/src/array_partition.jl +++ b/src/array_partition.jl @@ -223,12 +223,6 @@ end end end Base.filter(f, A::ArrayPartition) = ArrayPartition(map(x -> filter(f, x), A.x)) -Base.any(f, A::ArrayPartition) = any((any(f, x) for x in A.x)) -Base.any(f::Function, A::ArrayPartition) = any((any(f, x) for x in A.x)) -Base.any(A::ArrayPartition) = any(identity, A) -Base.all(f, A::ArrayPartition) = all(f, (all(f, x) for x in A.x)) -Base.all(f::Function, A::ArrayPartition) = all((all(f, x) for x in A.x)) -Base.all(A::ArrayPartition) = all(identity, A) for type in [AbstractArray, PermutedDimsArray] @eval function Base.copyto!(dest::$(type), A::ArrayPartition)