JuliaDiff / JuliaDiff/DiffResults.jl
Does `MutableDiffResult` have to exist at all?
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 37
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
Preliminary: DiffResult objects must always be realiased when updated, as mentioned in the docs
https://juliadiff.org/DiffResults.jl/stable/#DiffResults.value!
In most cases it is unnecessary, because the result object itself gets mutated. However, it causes a heap allocation to create the mutable struct defined here:
Here's a proof of concept: instead of the current code
we could instead return a new object every time
value!(r::MutableDiffResult, x::Number) = MutableDiffResult(x, r.derivs)
value!(r::MutableDiffResult, x::AbstractArray) = (copyto!(value(r), x); return r)
- Would it decrease or increase the performance of the update? Don't know
- Would it be considered a breaking change? Perhaps (see below)
- Would it break stuff in practice? Definitely (see below)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the value! documentation and the MutableDiffResult definition in src/DiffResults.jl at lines 19–25, then inspect the update code at lines 156–157. Compare the proposed behavior for scalar and array updates, and establish whether the change affects performance or compatibility. Done means a maintainer-approved decision on whether MutableDiffResult should remain and what API behavior is supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100