-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I just came across this while playing around in the REPL. I could see it potentially coming up in real life if somebody is using @memoize
in a script.
julia> using Memoization
julia> @memoize function foo(x::Int)
println("Computing...")
return 2x
end
foo (generic function with 1 method)
julia> foo(3)
Computing...
6
julia> foo(3)
6
julia> Memoization.caches[(typeof(foo), IdDict)]
IdDict{Any,Any} with 1 entry:
((3,), NamedTuple()) => 6
julia> @memoize function foo(x::String)
println("Computing...")
return x * "asdf"
end
foo (generic function with 2 methods)
julia> foo("hello")
Computing...
"helloasdf"
julia> foo("hello")
"helloasdf"
julia> Memoization.caches[(typeof(foo), IdDict)]
IdDict{Any,Any} with 1 entry:
(("hello",), NamedTuple()) => "helloasdf"
julia> foo(3)
Computing...
6
julia> Memoization.caches[(typeof(foo), IdDict)]
IdDict{Any,Any} with 2 entries:
(("hello",), NamedTuple()) => "helloasdf"
((3,), NamedTuple()) => 6
Metadata
Metadata
Assignees
Labels
No labels