I watched the [Move semantics for
Nim](https://www.youtube.com/watch?v=yA32Wxl59wo) talk.
It seems that the part of the problem in the previous code was the mutable
cache table, so compiler was unable to optimise the code with `move/sink/lent`.
I simplified the example and changed cache to be immutable, so the compiler
should be able to track the usage of the `prices` variable and optimize it. But
the code is still slow. Manually marking `get_prices` with `lent` improves it.
import sequtils
let prices = (1..100_000).to_seq.map(proc (i: int): float = i.float)
proc get_prices: seq[float] = prices
for _ in 1..100_000:
discard get_prices()[2]
Run