Skip to content

Commit 10f591e

Browse files
Remove redundant any/all methods on ArrayPartition to reduce invalidations
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 <accounts@chrisrackauckas.com>
1 parent 6cdda9c commit 10f591e

1 file changed

Lines changed: 0 additions & 6 deletions

File tree

src/array_partition.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,6 @@ end
223223
end
224224
end
225225
Base.filter(f, A::ArrayPartition) = ArrayPartition(map(x -> filter(f, x), A.x))
226-
Base.any(f, A::ArrayPartition) = any((any(f, x) for x in A.x))
227-
Base.any(f::Function, A::ArrayPartition) = any((any(f, x) for x in A.x))
228-
Base.any(A::ArrayPartition) = any(identity, A)
229-
Base.all(f, A::ArrayPartition) = all(f, (all(f, x) for x in A.x))
230-
Base.all(f::Function, A::ArrayPartition) = all((all(f, x) for x in A.x))
231-
Base.all(A::ArrayPartition) = all(identity, A)
232226

233227
for type in [AbstractArray, PermutedDimsArray]
234228
@eval function Base.copyto!(dest::$(type), A::ArrayPartition)

0 commit comments

Comments
 (0)