-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyconvert_add_rule() ignored if cache has been populated #336
Comments
Another posibility would be offering a resetting function function pyconvert_reset_cache!()
empty!(PYCONVERT_RULES_CACHE)
Core.eval(@__MODULE__, quote
@generated pyconvert_rules_cache(::Type{T}) where {T} = get!(Dict{C.PyPtr, Vector{Function}}, PYCONVERT_RULES_CACHE, T)
end)
end |
This issue has been marked as stale because it has been open for 30 days with no activity. If the issue is still relevant then please leave a comment, or else it will be closed in 7 days. |
Hi, I'll take a look. AFAIR calling |
Hi, just read that you are looking into this. function pyconvert_reset_cache!()
empty!(PythonCall.PYCONVERT_RULES_CACHE)
Core.eval(PythonCall, quote
@generated pyconvert_rules_cache(::Type{T}) where {T} = get!(Dict{C.PyPtr, Vector{Function}}, PYCONVERT_RULES_CACHE, T)
end)
end
function pyconvert_reset!()
empty!(PythonCall.PYCONVERT_RULES)
empty!(PythonCall.PYCONVERT_EXTRATYPES)
pyconvert_reset_cache!()
PythonCall.init_pyconvert()
end |
Currently, if I define a new rule from the beginning, everything works fine:
results in
However, if I do conversion once before the rule is defined, the conversion rules are cached and no conversion is performed. So far that's expected. But even if I delete the rule cache, the new rule is not applied.
results in
The reason is that somehow
@generated pyconvert_rules_cache
does not recalculate the value after the cache has been emptied.If I omit the
@generated
in front ofpyconvert_rules_cache
, the new rules are considered.If this is by design in order to gain performance, it's perhaps worth mentioning in the docs of
pyconvert_add_rule()
. Otherwise removing@generated
in convert.jl could be a solution.The text was updated successfully, but these errors were encountered: