fredrik-johansson/mpmath — pull request #3 by Krastanov (2012-11-23 14:40:37+00:00)
Title: Add initial ABC support.

We do not use subclassing in order to keep it as simple as possible. This
precludes the use of `@abstractmethod`, however it keeps the
`__init__`/`__new__` unchanged.

Not using subclassing/`@abstractmethod` means that checks whether the inferface
conforms to the requirements of the ABC are not done. Given the simplicity of
the interface in our case, this is the prefered approach. Conformity of the
interface is checked durring developpement.

Examples
========

`issubclass` works as well.

```
In [12]: import numbers

In [13]: import mpmath

In [14]: isinstance(mpmath.mpf(0.23), numbers.Complex)
Out[14]: True

In [15]: isinstance(mpmath.mpf(0.23), numbers.Real)
Out[15]: True

In [16]: isinstance(mpmath.mpf(0.23), numbers.Rational)
Out[16]: False
```

```
In [18]: isinstance(mpmath.mpc(0.23), numbers.Complex)
Out[18]: True

In [19]: isinstance(mpmath.mpc(0.23), numbers.Real)
Out[19]: False
```

```
In [20]: isinstance(mpmath.mpi(0.23), numbers.Complex)
Out[20]: True

In [21]: isinstance(mpmath.mpi(0.23), numbers.Real)
Out[21]: True

In [22]: isinstance(mpmath.mpi(0.23), numbers.Rational)
Out[22]: False
```

```
In [23]: isinstance(mpmath.mpi(0.23+1j), numbers.Complex)
Out[23]: True

In [24]: isinstance(mpmath.mpi(0.23+1j), numbers.Real)
Out[24]: False
```