# JuMPv0.21 and deepcopy

**URL:** <https://discourse.julialang.org/t/jumpv0-21-and-deepcopy/36051>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, deepcopy\
**Created:** [March 16, 2020, 6:03pm UTC](https://discourse.julialang.org/t/jumpv0-21-and-deepcopy/36051 "2020-03-16T18:03:44Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [March 17, 2020, 2:56am UTC](https://discourse.julialang.org/t/jumpv0-21-and-deepcopy/36051/6 "2020-03-17T02:56:44Z")

</div>

I will just chime in because this change (`deepcopy` throwing an error) was my contribution (first suggested by @Thuener [here](https://discourse.julialang.org/t/strange-behavior-with-deepcopy/23342/7), then suggested by me again [here](https://discourse.julialang.org/t/jump-gurobi-bug-value-of-variable-in-solved-model-changes-after-deleting-another-variable/29619/7), and finally implemented by me [here](https://github.com/JuliaOpt/JuMP.jl/pull/2079)).

The fact is: `deepcopy` has never ever worked, it always had basically the same behavior as `copy` that you say it is incompatible with your usage. There was never a code that correctly implemented `deepcopy` and now it was thrown out (replaced by an error), the fact `deepcopy` was implemented for JuMP.Model was mere accident, because `deepcopy` [is automatically defined for all types](https://github.com/JuliaLang/julia/blob/2d5741174ce3e6a394010d2e470e4269ca54607f/base/deepcopy.jl#L57) but this does not work correctly/out-of-the-box if the type in question has a pointer to an external C object.

If your code was working correctly with old `deepcopy` then either: it was incorrect; or it will work with `copy` too. The other solutions given in this thread are far better however.

---

_[View the full topic](https://discourse.julialang.org/t/jumpv0-21-and-deepcopy/36051)._
