# Shallow copy of an arbitrary mutable object

**URL:** https://discourse.julialang.org/t/shallow-copy-of-an-arbitrary-mutable-object/81140
**Category:** New to Julia
**Tags:** copy
**Created:** [May 16, 2022, 10:09am UTC](https://discourse.julialang.org/t/shallow-copy-of-an-arbitrary-mutable-object/81140 "2022-05-16T10:09:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![whatsthecraic](https://avatars.discourse-cdn.com/v4/letter/w/7bcc69/32.png) [@whatsthecraic](https://discourse.julialang.org/u/whatsthecraic)
#### Post date: [May 16, 2022, 10:09am UTC](https://discourse.julialang.org/t/shallow-copy-of-an-arbitrary-mutable-object/81140/1 "2022-05-16T10:09:15Z")

</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)`

---

<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: [May 16, 2022, 1:45pm UTC](https://discourse.julialang.org/t/shallow-copy-of-an-arbitrary-mutable-object/81140/2 "2022-05-16T13:45:38Z")

</div>

I think `Base.copy` may be the responsibility of the implementer of the type to implement. `Base.deepcopy` is “automatically generated” but this is because the concept of `deepcopy` is well-defined, but what exactly is _shallow_ is a little more hazy:

> Create a shallow copy of x: the outer structure is copied, but not all internal values.

vs

> Create a deep copy of x: everything is copied recursively, resulting in a fully independent object.
