Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add unsafe_convert method for CbcProblem. Resolve #100. #101
Add unsafe_convert method for CbcProblem. Resolve #100. #101
Changes from 2 commits
fe332f5
c59c0db
1aa92c1
c6b221b
1538144
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
filename
is a direct argument, no preserve needed?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.
So this one (and the one you commented on below) I'm not sure of. I think it could currently still be an issue if
writeMps
happens to get inlined, and given Stefan's comment, there don't seem to be future guarantees regarding input arguments anyway. Again, I'm not sure of the cost ofGC.@preserve
, but I'd assume it'd be negligible compared to theccall
.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.
The documentation makes a strong statement about ccall arguments: https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/#Garbage-Collection-Safety-1
I interpret that to mean that if this behavior changes it can only do so In a new major Julia release. I agree that the extra preserve is unlikely to have a performance impact. I'm nit picking so that we apply consistent rules and don't confuse someone who looks at this code and wonders why we preserved this particular argument when it's not needed.
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.
Would it be cleaner to define a
convert(::Type{Ptr{Cvoid}},::CbcModel)
method and just passprob
toccall
instead? See https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/#Auto-conversion:-1There 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 fully onboard with the nitpicking here since this has ramifications for many other packages. I think @andreasnoack's idea is a good one.
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.
Actually, according to https://docs.julialang.org/en/v1/base/c/#Base.cconvert,
So I think this should be a
Base.unsafe_convert
method.