#20624: maximum recursion depth exceeded in MonoDictEraser
-------------------------------+------------------------
Reporter: vbraun | Owner:
Type: defect | Status: new
Priority: major | Milestone: sage-7.3
Component: misc | Resolution:
Keywords: random_fail | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-------------------------------+------------------------
Comment (by nbruin):
Oh boy, it turns out `BuiltinFunction` does some shuffling around of
`_eval*_` methods, so looking at the source doesn't give a clear picture.
We really have to use introspection.
`ceil._evalf_(self,x,**kwds)` -> `return self.eval_(x)` [throws away
keywords!]
`ceil._eval_(self,*args)` -> `self._evalf_try_(*args)` or
`self._eval0_(*args)` if evalf_try returns None.
`ceil._evalf_try_(self,*args)` -> does some tests, but can end up calling
`self._evalf_(*args,parent=p)`. Does all of this inside a `try...except
Exception:pass`
whenever you run
{{{
ceil(x+2/5)(x=4.0)
}}}
the `_evalf_try_/_evalf_` loop will run out the python call stack, the
error will be caught by the try/except, `evalf_try` will then call
`ceil._eval0_(x)` which simply tries `x.ceil()` or some alternatives.
Strong evidence that this happens:
{{{
sage: sys.setrecursionlimit(<N>)
sage: %prun ceil(x+2/5)(x=4.0)
<N/4-epsilon>/1 0.003 0.000 0.003 0.003 {method
'_evalf_or_eval_' of 'sage.symbolic.function.BuiltinFunction' objects}
1 0.000 0.000 0.004 0.004 <string>:1(<module>)
<N/4-epsilon>1 0.000 0.000 0.003 0.003
other.py:501(_evalf_)
}}}
So the change is that apparently something has become collectible and that
now it can happen the garbage collector runs when the call stack is nearly
full, so that the Eraser classes don't have space to run.
The real solution is to stop `BuiltinFunction` from mangling methods. It
makes it very hard for people to write decent code. It's a horrible
design. Just looking at the implementation of ceil, everything seems to be
fine (although why would you implement `evalf` as `eval`?. With the magic
in BuiltinFunction, perhaps just deleting `evalf` does the trick)
--
Ticket URL: <http://trac.sagemath.org/ticket/20624#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.