On Wednesday 07 November 2007 08:33, Joel B. Mohler wrote:
> I'd like some confirmation for the patch at
> http://www.sagetrac.org/sage_trac/ticket/1075
> The purpose of the patch is to fix the lack of substitution in the
> following code snippet (it also has other ramifications in similar
> contexts): sage: R.<x,y>=ZZ[]
> sage: (x/y).subs({x:1})
> x/y
>
> ...
> 
> For some reason, which is a mystery to me, that code snippet works as
> expected if you replace ZZ with QQ.  I realize that behind the scenes that
> gives you an entirely different implementation (for the poly ring -- not
> the fractionfield), but I don't understand why the hash values somehow work
> out for the QQ case, but not the ZZ case.

Sorry to reply to myself when I should have done my research beforehand.  The 
issue is that multivariate polynomials over ZZ override hash and hash the 
tuple of tuples of exponents (roughly speaking).  This is in stark contrast 
to the default implementation that hashes the string representation of an 
object.  Thus, the hashes of mpolys over ZZ hash entirely differently than 
the fractionfield of mpolys over ZZ and hence the hashes are not equal.

This starts my thinking on a related tangent.  I've heard the sentiment that 
conversions to string need not be so fast since we are probably converting to 
show them to the user.  I agree with that sentiment, but here we are 
converting to string to hash the object -- and thus, it is extremely 
important to be fast (or else you've pretty much obliterated the point of 
using a dictionary).  I think this really is a point that bears more thought.

--
Joel

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to