On Thursday 29 February 2024 at 11:15:21 UTC-8 Dima Pasechnik wrote: How about using something like https://github.com/NeilGirdhar/extended_int ? (Even better, do a PEP to have such a thing in Python proper...) In old, totally duck-typed, Python this didn't really matter, but nowadays it does make a perfect sense.
At the moment, I think most degree functions do their best to return sage Integer objects; mainly so that coercion works well with them. So whatever solution we use should probably be based on objects that naturally live in the sage hierarchy. We do have an infinity object in sage and it already gets used for valuations. Incidentally: sage: R.<x>=LaurentSeriesRing(QQ) sage: z=R(0) sage: z.valuation() +Infinity sage: z.degree() -1 I don't quite know why laurent series have a degree defined at all, but they're keeping to the deg(0)=-1 convention. Incidentally: sage: A.<x>=QQ[] sage: B.<y>=LaurentPolynomialRing(QQ) sage: x.valuation(oo) -1 sage: y.valuation(oo) 1 so polynomial rings have a valuation (that will return +oo when appropriate), but on LaurentPolynomialRing this gets silently broken: the argument simply gets ignored and the valuation at 0 is returned. So I guess you can get a well-behaving degree with f=0*y -f(1/y).valuation() -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/053266d4-6fa6-4ac4-8ea0-61a3bf136758n%40googlegroups.com.