arrays - vector with 10^7 elements in scala -


i testing ruby, python , scala see 1 has better support huge arrays.

ruby (each) -> 84 mb, 2s # = [];(0...1e7).each{|i| a[i]=i} ruby (expand) -> 254 mb, 60s #a = [*(0...1e7)] python (numpy) -> 95 mb, < 1s # = np.arange(0, 1e7) python (range) -> 391 mb, < 1s # = list(range(0, int(1e7))) scala (range) -> memory limit exceeded :-) # var = range(0, 1e7.toint).map(_.toint) 

as can see, memory limit exceeds when using scala, what's problem?!!!

--update 

ok should've used

var = array.range(0, 1e7.toint) 

but, if want map array strings?

var b = a.map(_.tostring()) 

failure here...

scala's range isn't identical array in pure sense (inside doing additional work besides keeping n items, less memory efficient , eats memory faster).

array.range(0, 1e7.toint) closer python's np.arange , work fine.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -