Dear all,

As I'm sure most people here know, polynomials in Sage are kind of
immutable - they are meant to be immutable and (most) methods are
allowed to assume this to improve their performance, but sometimes
there an interface is (see _unsafe_mutate) to modify a polynomial
nonetheless.

I've recently come across two problems and would like some opinions on
this - I think they are bugs and if there is an agreement of this I'm
happy to write up a patch:

(1) Somewhere in polynomial_element.pyx, quoted from a comment on by
Harald on trac #4000, for some polynomial f in a univariate polynomial
ring with variable x,

{{{
sage: f(x) is f
Expected:
    True
Got:
    False
}}}

(I'm sorry for the vagueness, but I've first seen this in Harald's
comment, and he's using Sage 4.5.2 RC, which I am building only just
now.)  I think while the composition of a polynomial with its variable
*might* be allowed to take advantage of the immutability and return
self, I think it's going over the top to enforce that it actually
does.  That is to say, I think the check "f(x) == f" should definitely
return True, however, I don't think "f(x) is f" should be enforced to
return True.

(2) In the same file,

{{{
def __copy__(self):
    return self
}}}

I think it's great that many methods can improve their performance by
assuming that polynomials are immutable.  However, I think the copy
method should be an exception to this - after all, the caller is
explicitly asking for a "copy".

Thank you for your comments in advance,

Sebastian

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to