-
Notifications
You must be signed in to change notification settings - Fork 103
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
Fix loading of precompiled JSON when DataStructures is not present #126
Conversation
without DataStructures present
catch | ||
false | ||
function __init__() | ||
global _HAVE_DATASTRUCTURES = try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
global const
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Jameson hates it JuliaLang/julia#12010
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any harm in allowing this to be modified at runtime if someone really wants to. Would there be a performance impact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, globals are usually slower than constant globals because of the type instability... though maybe it doesn't matter here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only ever used as a boolean afaict - https://github.com/JuliaLang/JSON.jl/blob/0716a1ccc00e63461e03851387390fdcd43d0c35/src/Parser.jl#L322
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could annotate all usages, e.g., _HAVE_DATASTRUCTURES::Bool
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even annotating them is not nearly as efficient as a const
, last I checked the generated code. You could make it a const _HAVE_DATASTRUCTURES = [false]
.
Again, it could be that _HAVE_DATASTRUCTURES
is not used in any performance-critical situations, so maybe we shouldn't worry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to merge this then, fix what's broken. Adjusting constness can be done separately if it makes a difference.
Fix loading of precompiled JSON when DataStructures is not present
closes #123
first commit adds a test to demonstrate failure case on travis, then second commit moves the conditional dependency on DataStructures into an
__init__
function.