> ... In this situation, the significant amount of time spent is in the space 
> complexity part ...

I re-wrote same code in ruby, according to your statement it should be even 
slower, as Ruby has no memory locality optimization at all. But **Ruby version 
is blazing fast** , which suggest that it's not the memory locality that causes 
problem here.
    
    
    $prices = (1..100_000).map { |i| i.to_f }
    
    def get_prices() $prices; end
    
    (1..100_000).each do
      get_prices()[2]
    end
    
    
    Run

Reply via email to