, . ( ::Any !) , , - , , , .
, :
julia> function f()
y = rand(10)
@time y[1] + y[10]
z = deepcopy(y)
@time z[1] + z[10]
end
f (generic function with 1 method)
julia> f();
julia> f();
0.000000 seconds
0.000002 seconds (3 allocations: 48 bytes)
, , .
, 0.5 (, , ), . ,
julia> @code_warntype deepcopy(rand(2))
Variables:
x::Array{Float64,1}
Body:
begin
SSAValue(1) = (Core.ccall)(:jl_alloc_array_1d,(Core.apply_type)(Core.Array,Any,1)::Type{Array{Any,1}},(Core.svec)(Core.Any,Core.Int)::SimpleVector,Array{Any,1},0,32,0)::Array{Any,1}
return (Core.typeassert)((Base.deepcopy_internal)(x::Array{Float64,1},$(Expr(:new, :(Base.ObjectIdDict), SSAValue(1))))::Any,Array{Float64,1})::Array{Float64,1}
end::Array{Float64,1}
,
julia> f()
0.000000 seconds
0.000000 seconds
.