diff options
author | da-woods <dw-git@d-woods.co.uk> | 2023-03-20 09:38:44 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-20 10:38:44 +0100 |
commit | 7bb7ff04cac4047cb425acbf4e53cc94bc396c0a (patch) | |
tree | 8c87d595f1ec8c40114a7c135ae2e5de4661fb4b /tests | |
parent | c8b434c6041de474998fa3a9e779b8340c5b1f71 (diff) | |
download | cython-7bb7ff04cac4047cb425acbf4e53cc94bc396c0a.tar.gz |
Fix exception handling in memoryview utilitycode (GH-5325)
The new exception-handling semantics meant that the utility
code always had to check for exceptions on some void nogil functions
(requiring us to re-acquire the GIL). This made performance
noticeably worse under some circumstances.
Fix this by making the exception specifications noexcept
for quite a few cdef functions in the memoryview utility code.
Fixes https://github.com/cython/cython/issues/5324
Diffstat (limited to 'tests')
-rw-r--r-- | tests/compile/fused_redeclare_T3111.pyx | 12 | ||||
-rw-r--r-- | tests/errors/pure_warnings.py | 6 | ||||
-rw-r--r-- | tests/memoryview/memoryview_no_withgil_check.pyx | 11 |
3 files changed, 20 insertions, 9 deletions
diff --git a/tests/compile/fused_redeclare_T3111.pyx b/tests/compile/fused_redeclare_T3111.pyx index 5d1672198..53f087717 100644 --- a/tests/compile/fused_redeclare_T3111.pyx +++ b/tests/compile/fused_redeclare_T3111.pyx @@ -27,10 +27,10 @@ _WARNINGS = """ 36:10: 'cpdef_cname_method' redeclared # from MemoryView.pyx -979:29: Ambiguous exception value, same as default return value: 0 -979:29: Ambiguous exception value, same as default return value: 0 -1020:46: Ambiguous exception value, same as default return value: 0 -1020:46: Ambiguous exception value, same as default return value: 0 -1110:29: Ambiguous exception value, same as default return value: 0 -1110:29: Ambiguous exception value, same as default return value: 0 +980:29: Ambiguous exception value, same as default return value: 0 +980:29: Ambiguous exception value, same as default return value: 0 +1021:46: Ambiguous exception value, same as default return value: 0 +1021:46: Ambiguous exception value, same as default return value: 0 +1111:29: Ambiguous exception value, same as default return value: 0 +1111:29: Ambiguous exception value, same as default return value: 0 """ diff --git a/tests/errors/pure_warnings.py b/tests/errors/pure_warnings.py index 40104bc48..3109439cb 100644 --- a/tests/errors/pure_warnings.py +++ b/tests/errors/pure_warnings.py @@ -49,9 +49,9 @@ _WARNINGS = """ # Spurious warnings from utility code - not part of the core test 25:10: 'cpdef_method' redeclared 36:10: 'cpdef_cname_method' redeclared -979:29: Ambiguous exception value, same as default return value: 0 -1020:46: Ambiguous exception value, same as default return value: 0 -1110:29: Ambiguous exception value, same as default return value: 0 +980:29: Ambiguous exception value, same as default return value: 0 +1021:46: Ambiguous exception value, same as default return value: 0 +1111:29: Ambiguous exception value, same as default return value: 0 """ _ERRORS = """ diff --git a/tests/memoryview/memoryview_no_withgil_check.pyx b/tests/memoryview/memoryview_no_withgil_check.pyx new file mode 100644 index 000000000..4753bab12 --- /dev/null +++ b/tests/memoryview/memoryview_no_withgil_check.pyx @@ -0,0 +1,11 @@ +# mode: compile + +# cython: test_fail_if_c_code_has = __Pyx_ErrOccurredWithGIL + +# cython-generated memoryview code shouldn't resort to +# __Pyx_ErrOccurredWithGIL for error checking (because it's inefficient +# inside a nogil block) + +def assign(double[:] a, double[:] b): + with nogil: + a[:] = b[:] |