Skip to content

Commit fffd933

Browse files
committed
Pull Py_CompileString out of disable_sigint
Since `Py_CompileString` is unlikely to call Julia callback, there is no need to put it in `disable_sigint`. `@pycheckn` for `PyEval_EvalCode` is in `disable_sigint` because `PyErr_NormalizeException` may call the constructor of the exception class which may invoke Julia callbacks. This change may not be necessary but it seems to help Julia compiler inlining `ccall`.
1 parent dd2cbe0 commit fffd933

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/pyeval.jl

+8-7
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ pynamespace(m::Module) =
3131
# and a current "file name" to use for stack traces
3232
function pyeval_(s::AbstractString, globals=pynamespace(Main), locals=pynamespace(Main),
3333
input_type=Py_eval_input, fname="PyCall")
34-
disable_sigint() do
35-
o = PyObject(@pycheckn ccall((@pysym :Py_CompileString), PyPtr,
36-
(Cstring, Cstring, Cint),
37-
s, fname, input_type))
38-
return PyObject(@pycheckn ccall((@pysym :PyEval_EvalCode),
39-
PyPtr, (PyPtr, PyPtr, PyPtr),
40-
o, globals, locals))
34+
o = PyObject(@pycheckn ccall((@pysym :Py_CompileString), PyPtr,
35+
(Cstring, Cstring, Cint),
36+
s, fname, input_type))
37+
ptr = disable_sigint() do
38+
@pycheckn ccall((@pysym :PyEval_EvalCode),
39+
PyPtr, (PyPtr, PyPtr, PyPtr),
40+
o, globals, locals)
4141
end
42+
return PyObject(ptr)
4243
end
4344

4445
"""

0 commit comments

Comments
 (0)