Skip to content

Cache loaded data to avoid re-loading when cell re-runs? #2941

Discussion options

You must be logged in to vote

This seems to work:

begin
	if !isdefined(Main, :data_cache)
		setglobal!(Main, :data_cache, Dict{String, Any}())
	end
	data = map(paths) do p
		if haskey(Main.data_cache, p)
			Main.data_cache[p]
		else
			Main.data_cache[p] = load(p)
		end
	end
end

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by BioTurboNick
Comment options

You must be logged in to vote
1 reply
@BioTurboNick
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants