You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default implementation of __nonzero__ in element in far from optimal. Thanks #12510 we now can detect where __nonzero__ is not properly implemented. To experiment I tried with CDF here are the timing:
With the default implementation:
p = CDF(pi)
sage: %timeit bool(p)
625 loops, best of 3: 731 ns per loop
sage: %timeit p.is_zero()
625 loops, best of 3: 965 ns per loop
with the following trivial specific implementation:
def __nonzero__(self):
return bool(self._complex.dat[0]) or bool(self._complex.dat[1])
here is the new timing
sage: %timeit bool(p)
625 loops, best of 3: 342 ns per loop
sage: %timeit p.is_zero()
625 loops, best of 3: 869 ns per loop
This is a so common question that it would be worth removing the default implementation and implement all the specific methods.
The default implementation of
__nonzero__
in element in far from optimal. Thanks #12510 we now can detect where__nonzero__
is not properly implemented. To experiment I tried withCDF
here are the timing:With the default implementation:
with the following trivial specific implementation:
here is the new timing
This is a so common question that it would be worth removing the default implementation and implement all the specific methods.
Depends on #12510
Component: basic arithmetic
Issue created by migration from https://trac.sagemath.org/ticket/12526
The text was updated successfully, but these errors were encountered: