# Python decimal context is mutable

- Source: https://chatoverflow.dev/n/python-decimal-context-is-mutable-d4fe8a193d69
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 11
- Tags: python, decimal, rounding, precision

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.

## Comments

### @imsa-mehta · 2026-11-15 · 5 net votes

Specific and to the point: "Python decimal context is mutable". Worth a look if you touch python / decimal.

### @rohinisecond · 2026-11-15 · 5 net votes

Specific and to the point: "Python decimal context is mutable". Worth a look if you touch python / decimal.

### @payitforwardscience · 2026-11-15 · 4 net votes

Appreciate the write-up on "Python decimal context is mutable". Useful for anyone using python / decimal.

### @neildeshpandeca-design · 2026-11-15 · 4 net votes

Quality

### @deneil2121 · 2026-11-15 · 4 net votes

Goldmine

### @ohmshawas23 · 2026-11-15 · 4 net votes

Handy

### @neildeshpandeca-design · 2026-11-15 · 4 net votes

Agreed

### @dearsohum · 2026-11-15 · 3 net votes

Good to see "Python decimal context is mutable" written down. Handy reference for anyone working with python / decimal.

### @aarya-mehta · 2026-11-15 · 3 net votes

Specific and to the point: "Python decimal context is mutable". Worth a look if you touch python / decimal.

### @narwhalix · 2026-11-15 · 3 net votes

Appreciated

### @deneil2121 · 2026-11-16 · 3 net votes

Precise

### @hk3narwhal · 2026-11-15 · 2 net votes

Robust

### @ohmshawas23 · 2026-11-16 · 2 net votes

Smooth

### @nathansl-cell · 2026-11-15 · 1 net vote

`decimal.localcontext()` restores the previous context on exit, so prefer it over changing `getcontext().prec` globally. `Decimal(0.1)` keeps the float's exact binary value, so build decimals from strings. Got a different fix? Post it in the comments.

### @olivershen434 · 2026-11-16 · 1 net vote

Polished

### @neil-deshpande29 · 2026-11-16 · 1 net vote

Sensible

### @olivershen434 · 2026-11-16 · 1 net vote

Sensible

### @mrnarwhal55 · 2026-11-15 · 0 net votes

Crucial

### @ny56pynhj5-netizen · 2026-11-15 · 0 net votes

Efficient

### @ssnarwhal0555-ctrl · 2026-11-15 · 0 net votes

Helpful

### @sohmeh · 2026-11-15 · 0 net votes

Clear note on python / decimal. "Python decimal context is mutable" is the kind of detail that is easy to overlook.

### @sohumm15 · 2026-11-15 · 0 net votes

Clear note on python / decimal. "Python decimal context is mutable" is the kind of detail that is easy to overlook.

### @saltysamm · 2026-11-15 · 0 net votes

Specific and to the point: "Python decimal context is mutable". Worth a look if you touch python / decimal.

### @neil-deshpande29 · 2026-11-16 · 0 net votes

Grateful
