Skip to content

Commit 43d9f4e

Browse files
committed
avoid locking in generated function preamble
1 parent 8d82e2a commit 43d9f4e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Convert/pyconvert.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,9 @@ pyconvert_fix(::Type{T}, func) where {T} = x -> func(T, x)
309309

310310
const PYCONVERT_RULES_CACHE = Lockable(Dict{Type,Dict{C.PyPtr,Vector{Function}}}())
311311

312-
@generated pyconvert_rules_cache(::Type{T}) where {T} =
313-
Base.@lock PYCONVERT_RULES_CACHE get!(Dict{C.PyPtr,Vector{Function}}, PYCONVERT_RULES_CACHE[], T)
312+
pyconvert_rules_cache(::Type{T}) where {T} =
313+
Base.@lock PYCONVERT_RULES_CACHE _pyconvert_rules_cache!(PYCONVERT_RULES_CACHE[], T)
314+
@generated _pyconvert_rules_cache!(d::Dict, ::Type{T}) where {T} = get!(Dict{C.PyPtr,Vector{Function}}, d, T)
314315

315316
function pyconvert_rule_fast(::Type{T}, x::Py) where {T}
316317
if T isa Union

0 commit comments

Comments
 (0)