python decimal library dmath.py v0.3 released

Wolfgang Maier xpysol at gmail.com
Mon Mar 3 12:23:13 EST 2014


Am Montag, 3. März 2014 12:34:30 UTC+1 schrieb Mark H. Harris:
> hi folks,
> 
> 
> 
> Python Decimal Library dmath.py v0.3 Released
> 
> 
> 
> https://code.google.com/p/pythondecimallibrary/
> 
> 
> 
> This code provides the C accelerated decimal module with 
> 
> scientific/transcendental functions for arbitrary precision. 
> 
> I have also included pilib.py which is a PI library of historic
> 
> algorithms for generating PI, which uses dmath.py. 
> 
> 
> 
> I wish to thank Oscar, Wolfgang, Steven, Chris (and others)
> 
> for the help you gave me understanding decimal, particularly
> 
> format, rounding, and context managers. 
> 

Hi Marcus and thanks for the acknowledgement.
Here's one more suggestion for your code.
Your current implementation of fact() for calculating factorials has nothing to offer that isn't provided by math.factorial. Since this is all about Decimal calculations, shouldn't you modify it to something like:

def fact(x):
    """ fact(x)    factorial    {x} int x > 0        

            (x must be integral)
    """    
    return +Decimal(math.factorial(x))

to make it return a Decimal rounded to context precision?



More information about the Python-list mailing list