-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Do not cache the non-existence of coerce/convert map too often, and do not pretend that there is a conversion where it doesn't make sense at all #13378
Comments
This comment has been minimized.
This comment has been minimized.
comment:2
Are you sure
should not raise an error? Shouldn't the argument be a parent? Something like:
This has the potential for getting hairy if you want this to work:
because then I know this all flies in the face of duck typing, but so does the whole category framework. I'm afraid that a fully duck typed computer algebra system would about as bad as an untyped one. |
comment:3
Replying to @nbruin:
No, I am not sure.
Or a type, because we want a coercion (not just a conversion) between Python ints and Sage integers.
That's totally separate.
ZZ has no parent, it is a parent. Elements have a parent, but parents have a category.
parent(X) currently returns the type of X, if X has no method Anyway. I tried to introduce a shortcut for Result: It nearly worked. There was one segfault in sage.rings.polynomial.infinite_polynomial_element (which I wrote) and one doctest error. |
comment:4
Replying to @nbruin:
One could say that the category framework is the opposite of duck typing: In duck typing, you'd test whether certain methods are available for X, and conclude that X belongs to the category of ducks. In the category framework, you would at some point initialise X as an object of the category of ducks, and the category then provides X with methods like "quack()", "swim()", "fly()" --- or, if the category framework can not provide generic methods, it does require that these methods are implemented. But I actually think that's a strength of the category framework. And note that after category initialisation of X, it would to some extent be possible to determine |
comment:5
Ah yes, keeping that distinction strict is probably a good idea, even if it's
so an ideal is an element and not a parent (although mathematically it's also a
And here we're not getting a parent "... of submodules of V", whatever the ... Along these lines, by the way:
illustrating the usual schism between algebraists and number theorists. I don't think I'm really trying to make any point here. I'm just checking to |
Attachment: trac_13378-convert_map_shortcut.patch.gz Test validity of input before a (failing) construction of coercion |
Author: Simon King |
comment:6
I am not totally sure if the patch has dependencies, but let's test. With the patch, it is tested whether the input is valid as the domain of a conversion map or a coercion map. There is a difference between the two cases! Namely, Sequences are OK for a conversion map, but not for a coercion map. If the input S is invalid, |
comment:8
Could you clarify under what circumstances not having this code pollutes the cache? In particular, it seems that [coerce|convert]_map_from is always called with parent(x) which should always return a Parent or type? Perhaps what I'm asking is what object violate this in their parent() method. |
comment:9
Replying to @robertwb:
Unfortunately, I did not write in the ticket description what use case made me create this ticket. But probably it was some experimental code on the computation of Ext algebras of basic algebras (i.e., finite-dimensional path algebra quotients). Anyway. The problem is that in the coercion code one quite typically has
without checking whether P really is a category object or type. And that means trouble, if P happens to be, say, an element (Yes, that did occur! But I don't know where I had originally found it). See the ticket description for an example. Of course, if P is neither a category object nor a type, then there is no coercion map from P to self. And as you know, the coercion framework would not only cache a coercion map from P to self, but it would also cache the non-existence of a coercion map from P to self. So, the trouble starts if P runs over many elements that are not weakreffable. For each element P, the coercion framework would store the value |
comment:10
PS: If P is not a category object nor a type, it is impossible that there is a coercion map from P to self. Therefore the patch introduces a short cut: |
comment:11
Didn't it happen with integer ? (I think python ints.) |
comment:12
Some info here #13400 comment:31 but this ticket was opened before so... |
comment:13
Thank you, Jean-Pierre! Yes, it seems So, doing |
comment:14
Too bad/good, I just tested it with sage-5.6.beta1:
So, the problem mentioned at #13400 does currently not exist. We should investigate why it is not a problem. |
comment:18
Straightforward patch that applies (with slight whitespace fuzz for me) and doctests succeed. Plus it solves a real regression. At this pace, Sage 5.7 will have a negative memory footprint! yay. Positive review. |
Reviewer: Nils Bruin |
comment:21
Please don't add dependencies that aren't required for the patches to apply. The fix here can be applied independently of other tickets and makes sense too. It might solve a problem that doesn't become quite as apparent without those other tickets, but that has little to do with its applicability. We've had problems before where tickets were unnecessarily dequeued due to superfluous dependencies on tickets that turned out to need further work. Also, #12313 already states it's dependent on #12215, so there's no need to repeat that dependence here. |
comment:24
I guess it's a matter of definitions. I consider "merge with" as an equivalence relation (symmetric and transitive). Given that #12313 is to be merged with #13378 and #12215 is to be merged with #12313, the logical conclusion is that these 3 tickets need to be merged together. I didn't use the phrase "merge with" here, only to make the order of merging more clear (first #12215, then #12313, then #13378).
I find it easier to have the full set of dependencies written down. Consider tickets A, B and C where A and B have positive review, C needs review, A depends on B and B depends on C. If the implicit dependency of A on C is not written down, then it's not obvious to the release manager that A cannot currently be merged. |
Merged: sage-5.7.beta0 |
Sorry for the long ticket title.
About the first part of the title:
Hence, there is a reference to x in the coercion cache for P. OK, by #715 and friends, the reference is weak --- unless x does not allow weak references, in which case the reference will be strong, and x would not be collectable. Hence, a potential memory leak.
About the second part:
or
I think it is not good that the error occurs. The answer of
ZZ.convert_map_from(1)
seems strange, but apparently those things actually occur, namely conversions from the category of sequences.CC: @nbruin @jpflori
Component: coercion
Keywords: coercion conversion object cache
Author: Simon King
Reviewer: Nils Bruin
Merged: sage-5.7.beta0
Issue created by migration from https://trac.sagemath.org/ticket/13378
The text was updated successfully, but these errors were encountered: