On Aug 27, 9:05 pm, "Craig Citro" <[EMAIL PROTECTED]> wrote:
> I also vote for fast -- but couldn't there be a flag for the slow
> option? Maybe "consistent=True" or something, in case someone really
> wants it?
AFAIK, the key requirement for a hash function is that equivalent (in
the sense of "==") objects must have the same hash.
A natural situation in which one wants consistent cache is like this:
sage: M=MatrixSpace(GF(3),10,10).random_element()
sage: N=M.change_ring(ZZ)
sage: M.set_immutable()
sage: N.set_immutable()
sage: D={M:1}
sage: D[N]
This should work, because
sage: M==N
True
But it doesn't (KeyError), if hash(M) is different from hash(N).
And how should one pass the argument "consistent=True" in that
situation?
Hence the "key" question is: Should it be possible to get a dictionary
item by using an equivalent (yet different) key?
Certainly the answer is "yes".
Hence, either in the above situation one should have M!=N (which
wouldn't be nice) or they should have the same hash.
Yours
Simon
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
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://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---