ANN: GMPY2 or How I learned to love "nan"

casevh casevh at gmail.com
Thu Jun 9 02:51:25 EDT 2011


Everyone,

I'm pleased to announce a new alpha release of GMPY2.
GMPY2 is a wrapper for GMP and MPFR multiple-precision
arithmetic libraries.

GMPY2 alpha2 introduces context manager support for
MPFR arithmetic. It's now possible to trigger an exception
when comparing against "nan" (and other for other
events that normally generate "nan" or "inf").

>>> import gmpy2
>>> gmpy2.context().trap_erange=True
>>> gmpy2.mpfr("nan") == gmpy2.mpfr("nan")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
gmpy2.RangeError: comparison with NaN

If you have an interest in multiple-precision arithmetic
or want more control over the handling of exceptional
events in floating point arithmetic, please check out
GMPY2!

GMPY2 is available for download from:

http://code.google.com/p/gmpy/

Experimental release
--------------------

To simplify the codebase, allow for changes in the API,
and support simultaneous installation, the development
version has been renamed to GMPY2. The following is list
of changes in GMPY2:


In 2.0.0a0
----------

 * support for a mutable integer type "xmpz"
 * removal of random number functions
 * "xmpz" supports slices for setting/clearing bits
 * some methods have been renamed (scan1 -> bit_scan1)
 * support for Python prior to 2.6 has been removed
 * support for all division modes has been added
    * ceiling - round to +Infinity
    * floor - round to -Infinity
    * truncate - round to zero
    * 2exp - division by a power of 2
 * support is_even() and is_odd()

In 2.0.0a1
----------

 * support for the MPFR floating point library

In 2.0.0a2
----------
 * context manager support from controlling MPFR
   arithmetic
 * can raise Python exceptions when exceptional events
   occur with MPFR arithmetic; for example, comparing
   against "nan" can trigger an exception
 * more complete coverage for MPFR
 * many function names were changed to be more consistent

Please report any issues!

casevh




More information about the Python-list mailing list