[issue39576] Surprising MemoryError in `decimal` with MAX_PREC

Tim Peters report at bugs.python.org
Fri Feb 7 13:35:53 EST 2020


Tim Peters <tim at python.org> added the comment:

Formulas based on physical RAM probably work well on Linux, but not so well on Windows:  Windows has no "overcommit".  Whether a virtual memory request succeeds on Windows depends on how much RAM (+ swap space, if any) has already been requested across all processes.  It doesn't matter whether pages have actually been created, merely the total number of pages that _may_ be created.

I never bumped into this issue before, because I never used MAX_PREC before ;-)  When I intended to do exact arithmetic in `decimal`, I did this instead:

- guesstimated the max number of decimal digits a computation would need

- set `prec` to be comfortably - but not massively - larger than that

- enabled the Inexact trap, so if I guessed too low I'd get an exception

Maybe the docs could suggest that instead?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39576>
_______________________________________


More information about the Python-bugs-list mailing list