ProbabilityBoundsAnalysis.jl icon indicating copy to clipboard operation
ProbabilityBoundsAnalysis.jl copied to clipboard

Store global variables in a `const` structure

Open dpsanders opened this issue 3 years ago • 2 comments

Using global variables as in https://github.com/AnderGray/ProbabilityBoundsAnalysis.jl/blob/652700c7d2e1853f189b463d0786fd2f3c467f16/src/ProbabilityBoundsAnalysis.jl#L70 is a performance trap.

To fix this, I suggest grouping all the global variables into a mutable struct, which you refer to via a const global. See e.g.

https://github.com/JuliaIntervals/IntervalArithmetic.jl/blob/db9202ccd08402d05616442f395e88cb21f79b9b/src/intervals/precision.jl

for a similar design.

dpsanders avatar Feb 07 '22 02:02 dpsanders

Part of the review for the JuliaCon proceedings: https://github.com/JuliaCon/proceedings-review/issues/96

dpsanders avatar Feb 07 '22 02:02 dpsanders

Thank you for this suggestion. I have followed the example from IntervalArithmetic.jl. In future it would be good to also remove these globals

AnderGray avatar Mar 04 '22 16:03 AnderGray