# Unexpected copy when pushing

**URL:** <https://discourse.julialang.org/t/unexpected-copy-when-pushing/21495>\
**Category:** New to Julia\
**Created:** [March 5, 2019, 2:59pm UTC](https://discourse.julialang.org/t/unexpected-copy-when-pushing/21495 "2019-03-05T14:59:43Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 6, 2019, 4:37pm UTC](https://discourse.julialang.org/t/unexpected-copy-when-pushing/21495/8 "2019-03-06T16:37:36Z")

</div>

> [@jbaxter](#):
>
> I know Julia uses pass by sharing

No. For immutables, it is actually _undefined_ what happens under the hood, when the user can’t tell the difference. This gives the compiler room for optimizations, see eg [a recent discussion](https://discourse.julialang.org/t/how-are-called-in-julia-terminology-int64-float64-vs-array-t-1-tuple-t1-t2-set-t/21006/6).

> [@jbaxter](#):
>
> Is there a general rule about when Julia makes a _copy_ of a mutable value instead of passing a reference

I think that the general rule in `Base` and the standard library is that things are never copied implicitly, but _converted_ when necessary. See

[https://docs.julialang.org/en/v1/manual/conversion-and-promotion/#When-is-convert-called?-1](https://docs.julialang.org/en/v1/manual/conversion-and-promotion/#When-is-convert-called?-1)

---

_[View the full topic](https://discourse.julialang.org/t/unexpected-copy-when-pushing/21495)._
