# Recursive inner functions a thousand times slower?

**URL:** <https://discourse.julialang.org/t/recursive-inner-functions-a-thousand-times-slower/85604>\
**Category:** Performance\
**Created:** [August 11, 2022, 4:43am UTC](https://discourse.julialang.org/t/recursive-inner-functions-a-thousand-times-slower/85604 "2022-08-11T04:43:21Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [August 11, 2022, 6:45am UTC](https://discourse.julialang.org/t/recursive-inner-functions-a-thousand-times-slower/85604/3 "2022-08-11T06:45:33Z")

</div>

I was playing around with this and can someone explain me this: Just by removing the type annotation I get 4x faster execution. In the meantime the `@code_warntype` code remains the same:

```julia
function f2(y)
    loop(x) = x > 0 ? 1 + loop(x-1) : 0
    loop(y)
end

```

In my machine `f(100)` runs in _14μs_ and `f2(100)` in _3μs_.

```julia
julia> @btime f2(100)
3.066 μs (2 allocations: 32 bytes)

```

What surprises me is that even `@code_llvm` code looks the same. Is there any way to understand what is going on here ?

---

_[View the full topic](https://discourse.julialang.org/t/recursive-inner-functions-a-thousand-times-slower/85604)._
