# Why is eachindex faster than 1:n?

**URL:** <https://discourse.julialang.org/t/why-is-eachindex-faster-than-1-n/13366>\
**Category:** New to Julia\
**Created:** [August 13, 2018, 12:45pm UTC](https://discourse.julialang.org/t/why-is-eachindex-faster-than-1-n/13366 "2018-08-13T12:45:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AmjadHD](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@AmjadHD](https://discourse.julialang.org/u/AmjadHD)\
**Post date:** [August 13, 2018, 12:45pm UTC](https://discourse.julialang.org/t/why-is-eachindex-faster-than-1-n/13366/1 "2018-08-13T12:45:12Z")

</div>

Why is `Base.OneTo(n)` faster than `1:n` (in indexing), I read that the lower bound is guaranteed (by the compiler) to be 1, but I don’t get How ? and Why isn’t `1:n`’s lower bound guaranteed to be 1 ? and why don’t the julia developpers make `colon(1, n)::Base.OneTo(n)`

---

<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:** [August 13, 2018, 12:53pm UTC](https://discourse.julialang.org/t/why-is-eachindex-faster-than-1-n/13366/2 "2018-08-13T12:53:15Z")

</div>

`Base.OneTo(n)` is known from its type to start at `1`. `1:n` cannot from its type be known to start at 1 (it has the same type as `2:n`).

> [@AmjadHD](#):
>
> why don’t the julia developpers make `colon(1, n)::Base.OneTo(n)`

It would be bad if `1:n` and `2:n` had different types.
