Hi Simon,

The result is that the hash is broken by default, since the string 
> representation can be changed *after* creation of the object, which 
> means that the hash value would change as well. There is a ticket fixing 
> it, though. 
>
> > I think the problem lies in that the hash is calculated when the object 
> is 
> > not fully constructed. The hash value should be calculated as the last 
> part 
> > of the initialization process, as the hash should be dependent on the 
> data 
> > that defines the object. As the "..Algebra.__init__" is expected to be 
> > placed at the beginning of the initialization code 
>
> Why? Is that a Python convention?


Isn't that a convention of objected-oriented programming? 

> , I think there should be 
> > a separate method say "..Algebra._set_hash_" that is executed manually 
> or 
> > automatically at the end of the initialization process. 
>
> If it is automatic, then it will probably be at the end of the 
> initialisation process of Parent.__init__ - but then the problem would 
> not be solved, because you insist to call Parent.__init__ (indirectly 
> via ...Ring.__init__) before the initialisation of your object is 
> completed. 
>
> If it is manual and *has* to be done, then obviously a common 
> mistake would result, namely to forget initialising the hash. 
>

Yeah, the problem is not easy to solve...

Perhaps another idea, that I could easily implement: We could ensure 
> that calling ...Ring.__init__(..., category=False) would initialise the 
> ring except for the category framework. Then, the third solution of your 
> problem would be 
>     def __init__(self, i): 
>         CommutativeRing.__init__(self, i.base_ring(), category=False) 
>         self._ideal = i 
>         self._init_category_(CommutativeRings()) # or whatever is 
> appropriate 
>

This is similar to my "manual" idea. 

Would that be acceptable to you? 
>

This seems to be a good solution for all, not just for me. :-)
 

>
> Cheers, 
> Simon 
>
>

-- 
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