# What do @inbounds and @inline do?

**URL:** <https://discourse.julialang.org/t/what-do-inbounds-and-inline-do/21432>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 3, 2019, 8:33pm UTC](https://discourse.julialang.org/t/what-do-inbounds-and-inline-do/21432 "2019-03-03T20:33:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [March 3, 2019, 8:33pm UTC](https://discourse.julialang.org/t/what-do-inbounds-and-inline-do/21432/1 "2019-03-03T20:33:54Z")

</div>

These two macros – `@inbounds` and `@inline` – get thrown around a lot when performance comes up.

- What exactly do they do?
- When should you use them?
- When should you not use them?

Also, are there other useful performance macros that people should be aware of?

// asking b/c I’m trying to sprinkle some speedups throughout a codebase

* * *

**edit:** this is the explain-like-im-five version of:

> [Performance Tips · The Julia Language](https://docs.julialang.org/en/v1/manual/performance-tips/)

---

<div class="post-metadata">

**Author:** ![bennedich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bennedich/32/4894_2.png) [@bennedich](https://discourse.julialang.org/u/bennedich)\
**Post date:** [March 3, 2019, 8:43pm UTC](https://discourse.julialang.org/t/what-do-inbounds-and-inline-do/21432/2 "2019-03-03T20:43:27Z")

</div>

Just making sure you saw the section on performance annotations? I was going to write something, but I don’t think I can explain it any better than this:

[https://docs.julialang.org/en/latest/manual/performance-tips/#man-performance-annotations-1](https://docs.julialang.org/en/latest/manual/performance-tips/#man-performance-annotations-1)

There’s also this similar topic; a bit old, but still relevant I think:

> [@Questions on a number of code acceleration techniques](https://discourse.julialang.org/t/questions-on-a-number-of-code-acceleration-techniques/4733):
>
> I have been trying to step up my game in Julia by thinking more parallel and speed to make the fastest version of my code, and I find myself faced with a number of not-so-thoroughly-documented options so I have a few questions: I understand that @inbounds drops checking the bounds when accessing an array element, but why would not using that be ever a use case? I assume every functioning piece of code should not have any array cross its bounds. So after testing my code, and making sure no out…

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [March 3, 2019, 10:38pm UTC](https://discourse.julialang.org/t/what-do-inbounds-and-inline-do/21432/3 "2019-03-03T22:38:29Z")

</div>

The performance documentation is quite extensive and written to be useful for normal (non-expert) julia users. It would be easier to help you if you pointed out specifically what parts you had troubles understanding.
