# Performance of array broadcasting

**URL:** <https://discourse.julialang.org/t/performance-of-array-broadcasting/4724>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 7, 2017, 7:05pm UTC](https://discourse.julialang.org/t/performance-of-array-broadcasting/4724 "2017-07-07T19:05:11Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 7, 2017, 7:24pm UTC](https://discourse.julialang.org/t/performance-of-array-broadcasting/4724/5 "2017-07-07T19:24:16Z")

</div>

(Don’t benchmark in global scope. Use `.=` for in-place assignment that fuses with operations like `.*`.)

Note that for initializing only two components, the overhead even of creating a view, or calling `broadcast`, or allocating a temporary array like `[1,1]` will be very significant. For such a smll array in an inner loop, the fastest things are to write out your own loop or to use something like the StaticArrays package.

---

_[View the full topic](https://discourse.julialang.org/t/performance-of-array-broadcasting/4724)._
