You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Julia stdlib defines Base.copy to perform a shallow copy of a collection type. At the moment, Sunny has a number of Base.copy overloads, but these actually follow deep (not shallow) copy semantics. (Although the precedent is confusing.) Note that we could simply define:
Maybe we should ask on the Julia forums if it is recommended for packages to implement Base.copy for custom types, even if the implementation just calls deepcopy.
For context, there can be some pretty severe memory unsafety "gotchas" when deepcopy interacts with C pointers, e.g., JuliaMath/FFTW.jl#261.
There is hope, however, that the memory dangers might be mitigated in a future Julia version: JuliaLang/julia#52037
The text was updated successfully, but these errors were encountered:
Print an error if non-positive `dt` is detected when constructing an integrator. A negative timesteps can be attained with a mutable update, e.g. `dyn.Δt *= -1`.
Also deprecate `Base.copy(::Langevin)`. We might add it back depending on the resolution to #193. The story here will continue to evolve, but for now it's safe to err on the side of a thinner public API.
Because of memory gotchas, let's avoid use of deepcopy in the Sunny codebase. For non-shallow copying, we can follow the convention clone_X. For example, Sunny already has a clone_system.
The Julia stdlib defines
Base.copy
to perform a shallow copy of a collection type. At the moment, Sunny has a number ofBase.copy
overloads, but these actually follow deep (not shallow) copy semantics. (Although the precedent is confusing.) Note that we could simply define:Is it good to include these definitions in Sunny, or should we remove them, since people can always use the built-in
deepcopy
?I'm unsure, because
deepcopy
seems to be generally discouraged:JuliaLang/julia#42796 (comment)
Maybe we should ask on the Julia forums if it is recommended for packages to implement
Base.copy
for custom types, even if the implementation just callsdeepcopy
.For context, there can be some pretty severe memory unsafety "gotchas" when
deepcopy
interacts with C pointers, e.g., JuliaMath/FFTW.jl#261.There is hope, however, that the memory dangers might be mitigated in a future Julia version:
JuliaLang/julia#52037
The text was updated successfully, but these errors were encountered: