# Optlevel with submodule

**URL:** https://discourse.julialang.org/t/optlevel-with-submodule/42628
**Category:** General Usage
**Created:** [July 6, 2020, 6:23pm UTC](https://discourse.julialang.org/t/optlevel-with-submodule/42628 "2020-07-06T18:23:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![matthieu](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@matthieu](https://discourse.julialang.org/u/matthieu)
#### Post date: [July 6, 2020, 6:23pm UTC](https://discourse.julialang.org/t/optlevel-with-submodule/42628/1 "2020-07-06T18:23:27Z")

</div>

I have a package that creates a submodule. I would like to use the optimization level 1 for everything except the submodule. If I use the code

```julia
module MyPackage
   if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@optlevel"))
       @eval Base.Experimental.@optlevel 1
   end
   module MySubmodule
   ....
   end
end

```

Does the optlevel get applied to the submodule `MySubmodule`? If yes, is there a way to avoid it?

---

<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: [July 6, 2020, 6:28pm UTC](https://discourse.julialang.org/t/optlevel-with-submodule/42628/2 "2020-07-06T18:28:15Z")

</div>

> [@matthieu](#):
>
> Does the optlevel get applied to the submodule too?

I recall asking this and got the answer that it inherets from the parent module.

---

<div class="post-metadata">

### Author: ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)
#### Post date: [July 6, 2020, 6:37pm UTC](https://discourse.julialang.org/t/optlevel-with-submodule/42628/3 "2020-07-06T18:37:01Z")

</div>

You could just manually set the optlevel to 2 again in the submodule.
