I’m not sure, what kind of optimizations are currently implemented regarding these plain Python loops in the JIT. 
Note that you are currently not using any tensors, but Python literals.
I assume the first optimizations would go into the usage of tensors.
If you define val = torch.zeros(1), you should see a speedup of the jitted models in comparison to the eager model.
However, you will not see any speedup compared to the pure Python function, since your code is not vectorized.
Vectorization usually gives you a good speedup and loops should be generally avoided, if possible.