# Example C vs Julia vs Python

**URL:** <https://discourse.julialang.org/t/example-c-vs-julia-vs-python/33120>\
**Category:** Performance\
**Created:** [January 8, 2020, 8:27pm UTC](https://discourse.julialang.org/t/example-c-vs-julia-vs-python/33120 "2020-01-08T20:27:12Z")\
**Posts on this page:** 2\
**Page:** 3

<div class="post-metadata">

**Author:** ![lungben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lungben/32/12314_2.png) [@lungben](https://discourse.julialang.org/u/lungben)\
**Post date:** [January 23, 2020, 5:48am UTC](https://discourse.julialang.org/t/example-c-vs-julia-vs-python/33120/41 "2020-01-23T05:48:08Z")

</div>

Sorry, I mean array (coming from Python, therefore mixed it up).

```julia
compileme([1, 2, 3, 4])

```

---

<div class="post-metadata">

**Author:** ![lungben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lungben/32/12314_2.png) [@lungben](https://discourse.julialang.org/u/lungben)\
**Post date:** [January 23, 2020, 6:44am UTC](https://discourse.julialang.org/t/example-c-vs-julia-vs-python/33120/42 "2020-01-23T06:44:52Z")

</div>

After thinking more about it, it is probably impossible for the compiler to savely assume that the length of an array does not change during loop execution.  
Length changes by statements inside the loop could in principle be detected / excluded by the compiler (however, this quickly can get quite complicated). Thread safety is probably an issue: an array passed as argument to a function could in principle be changed during loop execution by another thread.  
For mutable types (like tuples) this is not an issue, here the compiler seems to apply the optimization already.

[Previous page](https://discourse.julialang.org/t/example-c-vs-julia-vs-python/33120.md?page=2)
