I'm using Cython to compile a function to C, but get a "Unreachable code" warning. When I inspect the pyx file, I see an additional return locals() which I don't quite understand how it got there.
The code is generated by cython.inline:
cython.inline('return a * b + c if a > b else 0.0', a=1, b=2, c=3)
which produces a pyx file that looks like this:
def __invoke(double a, double b, double c):
return a * b + c if a > b^2 else 0.0
return locals()
The reason I am cythonizing this function is to improve performance. The above function is a simplification, but the basic elements are the same. Note that the inline function is not using numpy arrays. If anyone can think of a faster way to evaluate the expression, I am happy to try it out (the syntax for the original expression is a bit different, but I can compile it to any format).
Anyway, the main point of this question is to understand why and additional return statement has been added and how to remove it.
Update
This is the overhead I've noticed from the cython.inline calls (refers to conversation with @DavidW).
