Singleton objects are useful for more important things than optimising
'==' with 'is'. They represent 'sui generis' objects that have specific
behaviour. But that wasn't my point (not that you could have known it,
given that I forgot half the words in my final parenthesis). I meant
that having Integer(42) and Rational(42) being different, barely related
objects, is unintuitive and makes it hard to extend an existing
structure with additional objects. IIUC, to have something like
S.Infinity in Sage, you'd need to create a
TwoPointCompactifiedExtendedRealLine algebra and convert all your real
objects to it (granted, the last one seems to happen automagically).

+1.  When I was working on the doctests in the polys, I was fixing some bugs in 
the domains, and I noticed that it's much cleaner to have QQ(2, 1) not 
automatically convert to ZZ(2).  The SymPy domain required all kinds of special 
code to check for singletons and automatic casting like that, which would break 
if, for example, a new number was made into a singleton.


I think you are actually +1-ing here the opposite of Ronan's statement, or do I mis-understand what you are saying?

I would agree to that latter interpretation: Integer(1) and Rational(1) *should* be clearly distinguished, although related objects. This is even so in "ordinary mathematics", as can be seen with some (admittedly contrived) questions like "what is the cardinality of 1?".

--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
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/sympy?hl=en.

Reply via email to