-
Notifications
You must be signed in to change notification settings - Fork 6
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
getMath() is swapping objects somehow #9
Comments
Uhm ... just to make it easier for us to look at ... can you let us know what you would expect. |
I would hope to have the same reference returned. This is the case when I call it multiple times, but |
thanks .. that explains it ... unfortunately, this is not how it is implemented in libSBML. the call to setMath takes a constant ASTNode element, and assigns a clone of it to the element. (Otherwise multiple object would own the same node, which might result in memory corruption at a later point). So that would explain why you get a different result after the setMath call. The original node is untouched, and you would get one additional ASTNode for each setMath call. Or so it would be in C++ in which libsbml is written in. We are using SWIG to generate wrapper classes, so that the library can be used easily from for example python. And it does seem that the generated code creates a new wrapper object. So each call to getMath will give you a different wrapper object (at least it does so here). whenever you hold a reference to a wrapper object (as you do in your code with the variables a, b, c you already have a python object, and so no new one needs to be constructed for it. what surprises me, is that you get the same id for 2-4. As that is not the case if i just run things with a one liner like:
but when i run them all together i get:
so all that goes along is to say, you can't count on the python id of things. I'm not quite sure there is anything i can do about this behavior. |
This is not the kind of behaviour that is expected from a getter; is it returning the original and keeping a copy?
Somehow the memory handling is not working correctly
output:
expected:
The text was updated successfully, but these errors were encountered: