Small #JuliaLang tip: if you want to write several vectors to the same file, assuming that the dimensions coincide, you can do this just with
open("path", "w") do io
writedlm(io, [x y z])
end
**But! The command [x y z] generates a matrix, thus allocating a lot of memory**. Luckily, writedlm also accepts zip(x,y,z), which does the same and is orders of magnitude faster, since it does not allocate memory! #julia
@vbuendiar Have you tried using the JLD package instead? It's quite convenient as it can export any object or set of objects as a dict and you can easily re-load them into their original variable names. https://docs.juliahub.com/JLD2/O1EyT/0.4.0/
@vbuendiar True, but as one who prefers maximum code reusability, I much prefer a "one and done" solution unless I'm working with TONS of data, but I'm just lazy 😂
@johnabs Hahahaha, everything has its own use. Small stupid tests that the JLD2 through FileIO are slower than writedlm for my use case.
But sure it is an amazing way to store serialized data, I never liked to work with HDF5 because it felt weird in Python, but I will definitely give a chance to this for other applications. Thx!!
@johnabs Thanks! Probably would save up some time, since apparently constructing the dictionary allocates way less memory than the array construction [x y]. But for single vectors I believe the first option is still the best, as zip takes literally almost nothing (then one would have to benchmark if JLD is faster itself than writedlm, but that I haven't really checked).