RecursionError: maximum recursion depth exceeded in comparison for Decimal.quantize()
See original GitHub issueI’m getting an endless loop which seems to be triggered by Decimal.quantize()
calling RP2Decimal.__ne__
which then calls RP2Decimal.__eq__
which then calls Decimal.quantize()
again.
I presume there is something wrong with my numbers, which I have yet to investigate.
...
File "/home/rndstr/venv3/lib/python3.10/site-packages/rp2/rp2_decimal.py", line 40, in __eq__
return (self - other).quantize(CRYPTO_DECIMAL_MASK).__eq__(ZERO)
File "/usr/lib/python3.10/_pydecimal.py", line 2588, in quantize
if ans != self:
File "/home/rndstr/venv3/lib/python3.10/site-packages/rp2/rp2_decimal.py", line 43, in __ne__
return not self.__eq__(other)
File "/home/rndstr/venv3/lib/python3.10/site-packages/rp2/rp2_decimal.py", line 40, in __eq__
return (self - other).quantize(CRYPTO_DECIMAL_MASK).__eq__(ZERO)
File "/usr/lib/python3.10/_pydecimal.py", line 2588, in quantize
if ans != self:
File "/home/rndstr/venv3/lib/python3.10/site-packages/rp2/rp2_decimal.py", line 43, in __ne__
return not self.__eq__(other)
File "/home/rndstr/venv3/lib/python3.10/site-packages/rp2/rp2_decimal.py", line 40, in __eq__
return (self - other).quantize(CRYPTO_DECIMAL_MASK).__eq__(ZERO)
File "/home/rndstr/venv3/lib/python3.10/site-packages/rp2/rp2_decimal.py", line 69, in __sub__
return RP2Decimal(Decimal.__sub__(self, other))
File "/usr/lib/python3.10/_pydecimal.py", line 1257, in __sub__
return self.__add__(other.copy_negate(), context=context)
File "/home/rndstr/venv3/lib/python3.10/site-packages/rp2/rp2_decimal.py", line 64, in __add__
return RP2Decimal(Decimal.__add__(self, other))
File "/usr/lib/python3.10/_pydecimal.py", line 1202, in __add__
ans = self._rescale(exp, context.rounding)
File "/usr/lib/python3.10/_pydecimal.py", line 2625, in _rescale
if not self:
File "/usr/lib/python3.10/_pydecimal.py", line 815, in __bool__
return self._is_special or self._int != '0'
RecursionError: maximum recursion depth exceeded in comparison
Issue Analytics
- State:
- Created a year ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
What is the maximum recursion depth in Python, and how to ...
It works up to n=997 , then it just breaks and spits out a RecursionError: maximum recursion depth exceeded in comparison . Is...
Read more >maximum recursion depth exceeded while calling a Python ...
RecursionError : maximum recursion depth exceeded in comparison ... We have created a function named nested() which accepts one argument – n.
Read more >Python RecursionError: Maximum Recursion Depth Exceeded ...
RecursionError : Maximum Recursion Depth Exceeded in Comparison. Let's create a program to calculate the factorial of a number following the ...
Read more >json.dumps() lacks information about RecursionError related ...
'0' RecursionError: maximum recursion depth exceeded in comparison Details: I have encountered issue when porting my code from Python 2 to 3 ...
Read more >Python maximum recursion depth exceeded in comparison
The Solution. Python has raised a recursion error to protect us against a stack overflow. This is when the pointer in a stack...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ended up running it with Docker where it works, posting as it may help others running into the same issue:
Create
Dockerfile
In same dir run
Go to your directory with
input.ods
andinput.config
files, runI tried your files and they worked on my machine:
I wonder if other Python packages using Decimal and high-precision math work on your machine: it might be an experiment worth trying.