This might have been so before the abstract base classes and the numeric
tower implemented in 2.5 or 2.6, but now Python itself has a definite
interface for checking any object whether it is complex number, real,
rational or integer.

I think the correctTM solution would be to use the build-in numeric tower
and not create our own. A few months ago mpmath added basic support for
that same numeric tower,

This is mostly the same issue mentioned above - we are implemented a type
system (sometimes really poorly defined) instead of using what python
provides.

http://docs.python.org/2/library/numbers.html

PS It was implemented in 2.6, so there are historic reasons behind our
current class structure. So when we drop 2.5 we will have no reason to use
Integer(1) instead of int(1), except the need to have only basic in args.

I think this is an argument in favor of option 3 - the ability to reuse
what python already provides, whether strings for names or base classes for
numbers.


On 21 May 2013 11:01, Chris Smith <smi...@gmail.com> wrote:

>
> Somewhat related, why should we use Integer(1) and not int(1)?
>>
>
> These create little sympy-landmines if you have to remember which things
> give ints and which give Integers. e.g. Rational(2,3).q and
> multiplicity(2,12) are ints so you have to be careful how you use them. If
> all Integers are stored as ints then the consistency helps; but if
> sometimes a Rational can be produced then you can't do things like `if
> i.is_Integer` you have to do `if type(i) is int` or `if isinstance(i,
> int)`.  SymPy can't anticipate what you are going to do with the
> integer-like properties/return values but it can make your life a little
> easier by making them consistent.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to