You can safely use Decimal. It is really decimal under the hood, i.e. No database conversion errors. If you store
import decimal
d = decimal.Decimal('4.10500008')
there will be no loss of accuracy.
Just make sure you create numbers using strings, because otherwise you will have problems:
>>> decimal.Decimal(1.1)
Decimal('1.100000000000000088817841970012523233890533447265625')
against
>>> decimal.Decimal('1.1')
Decimal('1.1')
Another important thing to understand is that it decimal.Decimalalso carries accuracy:
>>> decimal.Decimal('1.10')
Decimal('1.10')
This is very useful when using financial applications.
For more info see https://docs.python.org/2/library/decimal.html
N.B.. Mark Dickinson , decimal , . decimal.getcontext().prec, - 28. ( ), , .