Open
Description
From sagemath/sage#39224
SageMath session:
sage: %%cython
....: from cysignals.signals cimport sig_on, sig_off, sig_occurred
....: from libc.stdlib cimport abort
....: def f():
....: try:
....: sig_on()
....: abort()
....: sig_off()
....: except:
....: raise ValueError
....: def g():
....: for i in range(50):
....: ignore = sig_occurred()
sage: %time g() # fast
CPU times: user 4 μs, sys: 0 ns, total: 4 μs
Wall time: 6.44 μs
sage: f()
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File /tmp/tmpgqxu9lji/spyx/_tmp_tmpfkjflhcs_tmp_f70vs9fj_pyx/_tmp_tmpfkjflhcs_tmp_f70vs9fj_pyx_0.pyx:5, in _tmp_tmpfkjflhcs_tmp_f70vs9fj_pyx_0.f()
4 try:
----> 5 sig_on()
6 abort()
RuntimeError: Aborted
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
Cell In[3], line 1
----> 1 f()
File /tmp/tmpgqxu9lji/spyx/_tmp_tmpfkjflhcs_tmp_f70vs9fj_pyx/_tmp_tmpfkjflhcs_tmp_f70vs9fj_pyx_0.pyx:9, in _tmp_tmpfkjflhcs_tmp_f70vs9fj_pyx_0.f()
7 sig_off()
8 except:
----> 9 raise ValueError
10 def g():
11 for i in range(50):
ValueError:
sage: %time g() # slow
CPU times: user 3.84 s, sys: 133 μs, total: 3.84 s
Wall time: 3.85 s
sage: raise RuntimeError
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 raise RuntimeError
RuntimeError:
sage: %time g() # fast again
CPU times: user 79.9 ms, sys: 0 ns, total: 79.9 ms
Wall time: 79.9 ms
Note the invocation of g()
that is marked # slow
.
Metadata
Metadata
Assignees
Labels
No labels