You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perhaps we should reconsider adopting https://github.com/jump-dev/MutableArithmetics.jl which has gotten some traction by now. To be clear: this does not invalidate all work done one the AA/Nemo/... mutable API, but rather it can complement it, and help us to fix some issues with its design and implementation.
For some background, this was originally brought up in kalmarek/GroupsCore.jl#21 by @blegat on @kalmarek's GroupsCore repository. I've been hesitant to support this, and @thofma and @fieker seemed rather sceptical about it.
But since then I've had a chance to watch the JuliaCon 2021 presentation on MutableArithmetics, and looked at their code and documentation. And at the same time, I tried to use some of our own mutable arithmetic, and found many gaps in what we provide, and some bugs (I think -- PRs will be submitted once I had a chance to write some test for and clean up what I added to Nemo)
Overall I think there are a few advantages to be had:
they carefully thought about dealing with aliasing issues, which we currently do not seem to do well in all cases (I'll have some upcoming PRs)
as far as I understand, their approach makes it easy (or at least easier) to find places where one "forgot" to implement mutable arithmetics, resulting in less than optimal code
their @rewrite macro for automatically rewriting an arithmetic expression to use mutating APIs seems pretty sweet
In addition, it seems (see here) like adding support for this won't be that much work, we just have to provide a few "adapter" functions and then "our" mutable API and "theirs" could be used in parallel.
The main work would be to add MA.mutable_copy methods and use them, but that's something I believe we have to do anyway (if not MA.mutable_copy then via our own analogue).
The main drawback in my eyes is that this adds an external dependency on something out of our control. However, the JuMP people seem reasonable enough, so I'd be willing to risk it.
Anyway, this would still be a major undertaking; but it can be done in separate steps
for now add our own analogues of mutable_copy and copy_if_mutable and start adding and using them; I'd try to make sure they match their MA counterparts exactly. Then if we later start using MutableArithmetics, it'll be a simple switch; and even if we don't use MA, then for people familiar with MA it'll be easier to use our code
have a simple prototype which explores this idea that we can provide both APIs simultaneously with minimal effort; say for starts, just deal with fmpz in Nemo and see how that works out. If it does, one can use it more in Nemo (and Singular, and elsewhere, and eventually in AA). If not, we can give it up.
Perhaps we should reconsider adopting https://github.com/jump-dev/MutableArithmetics.jl which has gotten some traction by now. To be clear: this does not invalidate all work done one the AA/Nemo/... mutable API, but rather it can complement it, and help us to fix some issues with its design and implementation.
For some background, this was originally brought up in kalmarek/GroupsCore.jl#21 by @blegat on @kalmarek's GroupsCore repository. I've been hesitant to support this, and @thofma and @fieker seemed rather sceptical about it.
But since then I've had a chance to watch the JuliaCon 2021 presentation on MutableArithmetics, and looked at their code and documentation. And at the same time, I tried to use some of our own mutable arithmetic, and found many gaps in what we provide, and some bugs (I think -- PRs will be submitted once I had a chance to write some test for and clean up what I added to Nemo)
Overall I think there are a few advantages to be had:
MA.mutable_copyandMA.copy_if_mutable, which we really should also offer for our types -- see also fix some deepcopy_internals: they need to call #955 were it is made clear that many of ourdeepcopymethods violate the Julia specification@rewritemacro for automatically rewriting an arithmetic expression to use mutating APIs seems pretty sweetIn addition, it seems (see here) like adding support for this won't be that much work, we just have to provide a few "adapter" functions and then "our" mutable API and "theirs" could be used in parallel.
The main work would be to add
MA.mutable_copymethods and use them, but that's something I believe we have to do anyway (if notMA.mutable_copythen via our own analogue).The main drawback in my eyes is that this adds an external dependency on something out of our control. However, the JuMP people seem reasonable enough, so I'd be willing to risk it.
Anyway, this would still be a major undertaking; but it can be done in separate steps
mutable_copyandcopy_if_mutableand start adding and using them; I'd try to make sure they match their MA counterparts exactly. Then if we later start usingMutableArithmetics, it'll be a simple switch; and even if we don't use MA, then for people familiar with MA it'll be easier to use our codefmpzin Nemo and see how that works out. If it does, one can use it more in Nemo (and Singular, and elsewhere, and eventually in AA). If not, we can give it up.