# \#copy

**URL:** https://discourse.julialang.org/tag/copy/608.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Avoiding a copy after removing missings from a vector](https://discourse.julialang.org/t/avoiding-a-copy-after-removing-missings-from-a-vector/130866)

<div class="topic-metadata">

**Author:** [@s-baumann](https://discourse.julialang.org/u/s-baumann)\
**Replies:** 9\
**Last updated:** [July 19, 2025, 2:27pm UTC](https://discourse.julialang.org/t/avoiding-a-copy-after-removing-missings-from-a-vector/130866 "2025-07-19T14:27:34Z")

</div>

In Julia I am trying to write a function that will (without copying) compute something from two vectors. As an example think of Pearson correlation (although it is not that). What I have got is: function get\_valid\_entr…

---

## [Which copy function should I overload?](https://discourse.julialang.org/t/which-copy-function-should-i-overload/129595)

<div class="topic-metadata">

**Author:** [@mhauru](https://discourse.julialang.org/u/mhauru)\
**Replies:** 9\
**Last updated:** [June 5, 2025, 7:42am UTC](https://discourse.julialang.org/t/which-copy-function-should-i-overload/129595 "2025-06-05T07:42:26Z")

</div>

I have an abstract type, call it Abe, subtypes of which may or may not be mutable. I want a function that I can call on Abes that will make a (deepish) copy of the ones that are mutable (or in some cases wrap objects tha…

---

## [Why can I \`deepcopy(nothing)\` but not \`copy(nothing)\`?](https://discourse.julialang.org/t/why-can-i-deepcopy-nothing-but-not-copy-nothing/112429)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 5\
**Last updated:** [April 3, 2024, 6:11am UTC](https://discourse.julialang.org/t/why-can-i-deepcopy-nothing-but-not-copy-nothing/112429 "2024-04-03T06:11:47Z")

</div>

I know it sounds silly but it is currently blocking an AD package of mine ^^ julia\> deepcopy(nothing) julia\> copy(nothing) ERROR: MethodError: no method matching copy(::Nothing)

---

## [Copy or view, issue](https://discourse.julialang.org/t/copy-or-view-issue/110395)

<div class="topic-metadata">

**Author:** [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Replies:** 1\
**Last updated:** [February 19, 2024, 10:56am UTC](https://discourse.julialang.org/t/copy-or-view-issue/110395 "2024-02-19T10:56:19Z")

</div>

Following Noteworthy Differences from other Languages · The Julia Language which says that: Julia arrays are not copied when assigned to another variable. After A = B, changing elements of B will modify A as well. To a…

---

## [Copying a Model?](https://discourse.julialang.org/t/copying-a-model/71246)

<div class="topic-metadata">

**Author:** [@chelseas](https://discourse.julialang.org/u/chelseas)\
**Replies:** 5\
**Last updated:** [February 12, 2024, 3:34pm UTC](https://discourse.julialang.org/t/copying-a-model/71246 "2024-02-12T15:34:05Z")

</div>

Hi, I was wondering if there has been progress on the front of being able to copy/deepcopy a model in JuMP? Currently what I do is re-encode everything into the model but the encoding process is rather long and I would …

---

## [What is supposed to be copied from the context menu of a plot?](https://discourse.julialang.org/t/what-is-supposed-to-be-copied-from-the-context-menu-of-a-plot/108522)

<div class="topic-metadata">

**Author:** [@homocomputeris](https://discourse.julialang.org/u/homocomputeris)\
**Replies:** 2\
**Last updated:** [January 9, 2024, 9:03am UTC](https://discourse.julialang.org/t/what-is-supposed-to-be-copied-from-the-context-menu-of-a-plot/108522 "2024-01-09T09:03:36Z")

</div>

What is supposed to be copies from the context menu of a plot and where can it be pasted?

---

## [Why is copying using a loop is much slower than \`copy\` for large arrays?](https://discourse.julialang.org/t/why-is-copying-using-a-loop-is-much-slower-than-copy-for-large-arrays/90633)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 10\
**Last updated:** [November 27, 2022, 3:25am UTC](https://discourse.julialang.org/t/why-is-copying-using-a-loop-is-much-slower-than-copy-for-large-arrays/90633 "2022-11-27T03:25:28Z")

</div>

julia\> function copy2(A::Array) B = similar(A); @inbounds @simd for i in eachindex(A, B) B\[i\] = A\[i\] end B end copy2 (generic function with 1 method) jul…

---

## [Performance with intermittent singleton dimensions](https://discourse.julialang.org/t/performance-with-intermittent-singleton-dimensions/86374)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 11\
**Last updated:** [September 3, 2022, 12:04pm UTC](https://discourse.julialang.org/t/performance-with-intermittent-singleton-dimensions/86374 "2022-09-03T12:04:00Z")

</div>

Hello performance aficionados. I was testing a bit the copy performance, to see if there may be caching issues with multidimensional array copies and am generally quite impressed. However, I found one case that may lead…

---

## [Small changes on large arrays of custom types: mutable or immutable? shallow or deepcopy?](https://discourse.julialang.org/t/small-changes-on-large-arrays-of-custom-types-mutable-or-immutable-shallow-or-deepcopy/82335)

<div class="topic-metadata">

**Author:** [@skraemer](https://discourse.julialang.org/u/skraemer)\
**Replies:** 3\
**Last updated:** [June 7, 2022, 12:56pm UTC](https://discourse.julialang.org/t/small-changes-on-large-arrays-of-custom-types-mutable-or-immutable-shallow-or-deepcopy/82335 "2022-06-07T12:56:51Z")

</div>

(I have previously asked this on the New to Julia category, but I think might rather belong here) There are a few things somehow all related about the following situation concerning mutability to which I can not find a …

---

## [Shallow copy of an arbitrary mutable object](https://discourse.julialang.org/t/shallow-copy-of-an-arbitrary-mutable-object/81140)

<div class="topic-metadata">

**Author:** [@whatsthecraic](https://discourse.julialang.org/u/whatsthecraic)\
**Replies:** 1\
**Last updated:** [May 16, 2022, 1:45pm UTC](https://discourse.julialang.org/t/shallow-copy-of-an-arbitrary-mutable-object/81140 "2022-05-16T13:45:38Z")

</div>

Hi there, is there any method to perform a shallow copy of a mutable object? My attempt of Base.copy(obj) failed with an error MethodError: no method matching copy(::MyArbitraryType)

---

## [Create new dataframe with minor changes](https://discourse.julialang.org/t/create-new-dataframe-with-minor-changes/80245)

<div class="topic-metadata">

**Author:** [@sai\_matcha](https://discourse.julialang.org/u/sai_matcha)\
**Replies:** 11\
**Last updated:** [April 30, 2022, 2:28am UTC](https://discourse.julialang.org/t/create-new-dataframe-with-minor-changes/80245 "2022-04-30T02:28:16Z")

</div>

Hi , I tried to create a new data frame with theminor changes from my original dataframe. But whenever i tried to change something in new dataframe, it gets changed in original as well. Can some one help me to solve thi…

---

## [Best Julian way to copy many files?](https://discourse.julialang.org/t/best-julian-way-to-copy-many-files/75142)

<div class="topic-metadata">

**Author:** [@chowerth](https://discourse.julialang.org/u/chowerth)\
**Replies:** 2\
**Last updated:** [January 24, 2022, 7:24pm UTC](https://discourse.julialang.org/t/best-julian-way-to-copy-many-files/75142 "2022-01-24T19:24:00Z")

</div>

Hello. I’m wondering what is the best Julian way to copy files. My particular use case is I have a large number of files (of varying size) and I’m automating their data cleaning and backup process. Without going into gr…

---

## [Macro for unpack and copy](https://discourse.julialang.org/t/macro-for-unpack-and-copy/63416)

<div class="topic-metadata">

**Author:** [@iHany](https://discourse.julialang.org/u/iHany)\
**Replies:** 3\
**Last updated:** [June 23, 2021, 7:16am UTC](https://discourse.julialang.org/t/macro-for-unpack-and-copy/63416 "2021-06-23T07:16:51Z")

</div>

Hi, I’m frequently use UnPack.jl to unpack data. For example, struct MyStr a b end mystr = MyStr(1, 2) @unpack a, b = mystr # a, b = mystr.a, mystr.b However, I sometimes need copy the unpacked values. For e…

---

## [Is it worth introducing \`copy()\` into learnxiny?](https://discourse.julialang.org/t/is-it-worth-introducing-copy-into-learnxiny/55965)

<div class="topic-metadata">

**Author:** [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Replies:** 4\
**Last updated:** [February 25, 2021, 4:11am UTC](https://discourse.julialang.org/t/is-it-worth-introducing-copy-into-learnxiny/55965 "2021-02-25T04:11:39Z")

</div>

Many new users use: Learn Julia in Y Minutes New users coming from Matlab/Octave (like myself) may not realize that using = w/ arrays does not create a new copy. a1 = \[1:5;\] a2 = a1 a2\[5\] = a2\[5\] +40 a2 a1 # a1 = \[1:5…

---

## [Why is \`copy(adjoint)\` not an adjoint object?](https://discourse.julialang.org/t/why-is-copy-adjoint-not-an-adjoint-object/55371)

<div class="topic-metadata">

**Author:** [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Replies:** 12\
**Last updated:** [February 18, 2021, 7:03am UTC](https://discourse.julialang.org/t/why-is-copy-adjoint-not-an-adjoint-object/55371 "2021-02-18T07:03:11Z")

</div>

This surprised me: julia\> typeof(copy(rand(4,4)')) Matrix{Float64} (alias for Array{Float64, 2}) julia\> typeof(deepcopy(rand(4,4)')) LinearAlgebra.Adjoint{Float64, Matrix{Float64}} I have an algorithm which looks pret…
