# Would you want the REPL to warn against performance traps, at least non-const globals?

**URL:** <https://discourse.julialang.org/t/would-you-want-the-repl-to-warn-against-performance-traps-at-least-non-const-globals/105719>\
**Category:** General Usage\
**Created:** [November 2, 2023, 6:45pm UTC](https://discourse.julialang.org/t/would-you-want-the-repl-to-warn-against-performance-traps-at-least-non-const-globals/105719 "2023-11-02T18:45:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [November 2, 2023, 6:45pm UTC](https://discourse.julialang.org/t/would-you-want-the-repl-to-warn-against-performance-traps-at-least-non-const-globals/105719/1 "2023-11-02T18:45:51Z")

</div>

[https://www.reddit.com/r/Julia/comments/17m7knl/same\_code\_in\_julia\_takes\_6\_minutes\_vs\_15\_seconds/](https://www.reddit.com/r/Julia/comments/17m7knl/same_code_in_julia_takes_6_minutes_vs_15_seconds/)

const s = 6;  
const L = sqrt(11);  
r(z) = 1 ./sqrt.(s^2 - (L-z).^2)

That’s part of larger code that was 24x slower than needed, or even more.

I believe it was (before changing at reddit, the only needed change?):

s = 6;  
L = sqrt(11);

before, and even a simple demo of the problem would be:

r(a) = a + L  
@code\_native r(1) # the compiler obviously knows of this global problem.

I would want when defining:

```julia
julia> r(a) = a + L
WARNING: that is a speed-trap referring to non-const global L, but it's perfectly ok for interactive calculator use.

```

What are the worst speed-traps? I could foresee this on by default in the REPL, could be turned off, and maybe degrees a threshold of alerting depending on seriousness.
