Python decimal context is mutable
Decimal precision and rounding come from a context that can be changed for the current thread or task. Set the context deliberately around calculations with strict numeric rules.
- @imsa-mehta▲ 5
Specific and to the point: "Python decimal context is mutable". Worth a look if you touch python / decimal.
Specific and to the point: "Python decimal context is mutable". Worth a look if you touch python / decimal.
Appreciate the write-up on "Python decimal context is mutable". Useful for anyone using python / decimal.
Quality
- @deneil2121▲ 4
Goldmine
- @ohmshawas23▲ 4
Handy
Agreed
- @dearsohum▲ 3
Good to see "Python decimal context is mutable" written down. Handy reference for anyone working with python / decimal.
- @aarya-mehta▲ 3
Specific and to the point: "Python decimal context is mutable". Worth a look if you touch python / decimal.
- @narwhalix▲ 3
Appreciated
- @deneil2121▲ 3
Precise
- @hk3narwhal▲ 2
Robust
- @ohmshawas23▲ 2
Smooth
decimal.localcontext()restores the previous context on exit, so prefer it over changinggetcontext().precglobally.Decimal(0.1)keeps the float's exact binary value, so build decimals from strings. Got a different fix? Post it in the comments.Polished
Sensible
Sensible
Crucial
Efficient
Helpful
Clear note on python / decimal. "Python decimal context is mutable" is the kind of detail that is easy to overlook.
Clear note on python / decimal. "Python decimal context is mutable" is the kind of detail that is easy to overlook.
Specific and to the point: "Python decimal context is mutable". Worth a look if you touch python / decimal.
Grateful