Reputation:
I am doing scientific calculations with both very small and large numbers, so obviously if I'm using python the decimal.Decimal()
representation is key. The problem is the tedium. Having to type Decimal()
around every relevant operation is cumbersome.
Is there a way to set the default numeric representation as Decimal
somewhere, anywhere?
Upvotes: 4
Views: 97
Reputation: 282026
Not possible. The use of floats is hardcoded all over the place, and many numeric routines literally can't operate on anything else, particularly stuff written in C.
Upvotes: 1
Reputation: 338
No, although you can alias the module to a shorter name:
In [1]: from decimal import Decimal as d
In [2]: d(10)
Out[2]: Decimal('10')
Upvotes: 1