-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance hints for nogil + pxd (#6088)
In order to be called efficiently, these functions must have the exception specification set in the pxd file since Cython is unable to assume an implicit exception specification. This improves the quality of the messages to draw attention to this detail. Closes #6001
- Loading branch information
Showing
7 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# mode: compile | ||
# tag: perf_hints | ||
|
||
# Compile only to avoid needing to compile definitions of the functions | ||
# declared in another pxd file | ||
|
||
from nogil_perf_hints_pxd cimport f_has_except_value, f_missing_except_value, f_noexcept | ||
|
||
def test(): | ||
with nogil: | ||
# should not generate performance hints | ||
f_has_except_value() | ||
f_noexcept() | ||
# should generate performance hints. | ||
# (Unfortunately it's difficult to check the extra information on the 2nd+ line of the hint) | ||
f_missing_except_value() | ||
|
||
_PERFORMANCE_HINTS = """ | ||
16:30: Exception check after calling 'f_missing_except_value' will always require the GIL to be acquired. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cdef int f_has_except_value() nogil except -1 | ||
cdef int f_missing_except_value() nogil | ||
cdef int f_noexcept() nogil noexcept |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
cdef void voidexceptnogil_in_pxd() nogil | ||
|
||
# These definitions are unhelpful to people cimporting | ||
# them because the exception value isn't in the pxd. | ||
cdef int f_in_pxd1() nogil | ||
cdef int f_in_pxd2() nogil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters