On Tue, Apr 29, 2014 at 10:57 PM, Robert Bradshaw
<[email protected]> wrote:
> On Tue, Apr 29, 2014 at 9:07 AM, Volker Braun <[email protected]> wrote:
>> On Tuesday, April 29, 2014 3:58:14 PM UTC+1, Simon King wrote:
>>>
>>> Yes there is! The hook is the hash function.
>>
>>
>> CPython implementation detail and subject to change... really Python makes
>> no guarantee that __hash__() is called at any particular point. Its of
>> course safe to normalize elements there for the hash, but you might be doing
>> it too early then.
>
> Might, but it's probably the better thing to do here.
>
> For a fraction field the equality a/b == c/d can easily be resolved
> without normalization as a*d == b*c. Similarly, for a fraction field
> over a polynomial ring, you can can also produce a hash without
> normalization by "evaluating" the numerator and denominator at a fixed
> point and using the hash of the resulting field element. May or may
> not be cheaper in practice, and you'd probably want to cache it.

Unfortunately this breaks hash(a) == hash(a / 1) unless hash is so
defined in the polynomial ring as well.

I posted a fix to simply always reduce.

>>> ... in some cases only a trivial hash function (such as: hash of the
>>> parent) should be used.
>>
>>
>> or, better, just 1: set([ZZ(1), QQ(1)])
>
> This is probably a bad idea--it'll lead to very poor and
> hard-to-diagnose performance issues.
>
> - Robert

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to