Closed vtjnash closed 1 year ago
Thanks for the suggestion! I implemented symbol memoization in https://github.com/Pangoraw/Coil.jl/commit/f0204ad2e84dffddb06f9920e3f75d8518e6c696.
Nice! One further small optimization to consider: you may want to only compute the handle when you need it for dlsym, and not earlier
you may want to only compute the handle when you need it for dlsym, and not earlier
Good catch, thanks!
This probably does not intend to be re-running dlopen on every call, since that is generally a bad idea. Instead, you can memoize it with a hidden
Ref
object, as roughly seen here: https://github.com/JuliaPy/PyCall.jl/pull/84/files (oddly, this feature was removed later in https://github.com/JuliaPy/PyCall.jl/pull/84/files)https://github.com/Pangoraw/Coil.jl/blob/389237f18ee056a3c73b98ccc7d468260ff17edb/src/utils.jl#L21-L22
Even that was a bit overcomplicated with the use of globals, since you just need a local Ref object:
(I don't define func, version, or how to get library here, but the first 2 come from the user, and the latter can be computed and stored globally at some earlier time or in some similar way)