From 1a3eefb3223611e5f6ec2de141a9bae836f36c7e Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Tue, 11 Nov 2025 19:08:11 +0100 Subject: [PATCH 1/2] Implement Base.IndexStyle for PyObjectArray using a type argument Base already defines a IndexStyle(::AbstractArray) method for object arguments that uses the object type, so we can implement that directly and avoid the invalidations from implement Base.IndexStyle(::PyObjectArray). --- src/JlWrap/objectarray.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JlWrap/objectarray.jl b/src/JlWrap/objectarray.jl index 92fb06ae..3b37f14c 100644 --- a/src/JlWrap/objectarray.jl +++ b/src/JlWrap/objectarray.jl @@ -10,7 +10,7 @@ PyObjectArray(x::AbstractArray{T,N}) where {T,N} = PyObjectArray{N}(x) pyobjectarray_finalizer(x::PyObjectArray) = GC.enqueue_all(x.ptrs) -Base.IndexStyle(x::PyObjectArray) = Base.IndexStyle(x.ptrs) +Base.IndexStyle(T::Type{<: PyObjectArray}) = Base.IndexStyle(fieldtype(T, :ptrs)) Base.length(x::PyObjectArray) = length(x.ptrs) From 7766cc82494cacaadd50fdf6a86a85ffd15126cf Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Tue, 11 Nov 2025 23:43:22 +0100 Subject: [PATCH 2/2] Remove unnecessary `Dates.value()` methods The Dates stdlib already defines a method that does the same thing for any `Period`. --- src/NumpyDates/InlineTimeDelta64.jl | 2 -- src/NumpyDates/TimeDelta64.jl | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/NumpyDates/InlineTimeDelta64.jl b/src/NumpyDates/InlineTimeDelta64.jl index 62d9e19f..ae9e20dd 100644 --- a/src/NumpyDates/InlineTimeDelta64.jl +++ b/src/NumpyDates/InlineTimeDelta64.jl @@ -24,8 +24,6 @@ end # accessors -Dates.value(d::InlineTimeDelta64) = d.value - unitpair(::InlineTimeDelta64{U}) where {U} = unitpair(U) unitpair(::Type{InlineTimeDelta64{U}}) where {U} = unitpair(U) diff --git a/src/NumpyDates/TimeDelta64.jl b/src/NumpyDates/TimeDelta64.jl index ab0f9b69..b63c31de 100644 --- a/src/NumpyDates/TimeDelta64.jl +++ b/src/NumpyDates/TimeDelta64.jl @@ -23,8 +23,6 @@ end # accessors -Dates.value(d::TimeDelta64) = d.value - unitpair(d::TimeDelta64) = d.unit # constructors