Re: [sage-support] Re: bug in comparison of function field elements

2014-04-30 Thread Robert Bradshaw
On Tue, Apr 29, 2014 at 10:57 PM, Robert Bradshaw wrote: > On Tue, Apr 29, 2014 at 9:07 AM, Volker Braun 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... re

Re: [sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread Robert Bradshaw
On Tue, Apr 29, 2014 at 9:07 AM, Volker Braun 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

[sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread Volker Braun
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 the

Re: [sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread John Cremona
On 29 April 2014 16:17, Nils Bruin wrote: > On Tuesday, April 29, 2014 7:47:39 AM UTC-7, Volker Braun wrote: >> >> Always putting things in canonical form will be slow (there is no hook for >> "you are about to be put into a set") and/or not possible (fp group >> elements). > > > I disagree in thi

Re: [sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread Nils Bruin
On Tuesday, April 29, 2014 7:47:39 AM UTC-7, Volker Braun wrote: > > Always putting things in canonical form will be slow (there is no hook for > "you are about to be put into a set") and/or not possible (fp group > elements). > I disagree in this particular case. Making the denominator monic is

Re: [sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread John Cremona
On 29 April 2014 15:56, John Cremona wrote: > > I will open a ticket... #16268 (see http://trac.sagemath.org/ticket/16268) > > John > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails f

Re: [sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread Volker Braun
On Tuesday, April 29, 2014 3:35:55 PM UTC+1, John Cremona wrote: > > On 29 April 2014 15:16, Volker Braun > > wrote: > > s and t are not the same expression, so they have different hashes. We > break > > Python by letting them compare equal. Hence the outcome of putting them > into > > sets i

[sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread Simon King
Hi Volker, On 2014-04-29, Volker Braun wrote: > Always putting things in canonical form will be slow (there is no hook for > "you are about to be put into a set") Yes there is! The hook is the hash function. If you need a hash (i.e., if you put it into a set or dict) then you need a canonical f

Re: [sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread John Cremona
On 29 April 2014 15:47, Volker Braun wrote: > On Tuesday, April 29, 2014 3:35:55 PM UTC+1, John Cremona wrote: >> >> On 29 April 2014 15:16, Volker Braun wrote: >> > s and t are not the same expression, so they have different hashes. We >> > break >> > Python by letting them compare equal. Hence

[sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread Simon King
Hi John, On 2014-04-29, John Cremona wrote: > That is a *very* unsatisfactory explanation for anyone actually > wanting to use Sage to do mathematics. +1 > That > function could easily be amended to do the second step, which would > make it more useful. ... and it should be used in the hash m

Re: [sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread John Cremona
On 29 April 2014 15:16, Volker Braun wrote: > s and t are not the same expression, so they have different hashes. We break > Python by letting them compare equal. Hence the outcome of putting them into > sets is undefined. In CPython: if the hash collides, you get one element. If > the hash does n

[sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread Volker Braun
s and t are not the same expression, so they have different hashes. We break Python by letting them compare equal. Hence the outcome of putting them into sets is undefined. In CPython: if the hash collides, you get one element. If the hash does not collide, you get two elements. On Tuesday, A

[sage-support] Re: bug in comparison of function field elements

2014-04-29 Thread Simon King
Hi John, On 2014-04-29, John Cremona wrote: > sage: s==t > True > sage: Set([s,t]) > {(27*u^2 + 81*u + 243)/(27*u - 81), (u^2 + 3*u + 9)/(u - 3)} Internally, a set would first distribute the given elements in "hash buckets". Elements in different hash buckets will not be compared by "==". And he