One of the pain points in Cython is that one must explicitly annotate non-object returning functions with except clauses. Would it be worth trying to change the default here, making exception-suppressing opt-in rather than opt-out? There are a couple of open questions, e.g. * What would the syntax be? * What about extern functions? * What would the performance impact be? Could it be mitigated?
Robert Bradshaw schrieb am 17.09.2018 um 15:44:
One of the pain points in Cython is that one must explicitly annotate non-object returning functions with except clauses. Would it be worth trying to change the default here, making exception-suppressing opt-in rather than opt-out?
There are a couple of open questions, e.g. * What would the syntax be? * What about extern functions? * What would the performance impact be? Could it be mitigated?
Probably a good idea, and worth a 3.0 ticket. Note that the default for return type annotations is to automatically propagate exceptions, in order to keep the drop from Python semantics gentle. @cython.cfunc def func() -> cython.int: ... is read as "except? -1", unless declared otherwise. Stefan
Robert Bradshaw schrieb am 17.09.2018 um 15:44:
One of the pain points in Cython is that one must explicitly annotate non-object returning functions with except clauses. Would it be worth trying to change the default here, making exception-suppressing opt-in rather than opt-out?
There are a couple of open questions, e.g. * What would the syntax be? * What about extern functions? * What would the performance impact be? Could it be mitigated?
One more point: what about nogil functions? They can, in theory, raise exceptions, but they almost never do in practice. Given that the default for return type annotations is exception propagation (i.e. Python semantics) now, mixing that into a nogil function means that the caller would almost always check for exceptions needlessly. And we do not currently have a way to say "no exception return value" to get rid of that check. That's something we'd need, especially if we change the default. Stefan
On Wed, Sep 19, 2018, 5:04 PM Stefan Behnel <stefan_ml@behnel.de> wrote:
Robert Bradshaw schrieb am 17.09.2018 um 15:44:
One of the pain points in Cython is that one must explicitly annotate non-object returning functions with except clauses. Would it be worth trying to change the default here, making exception-suppressing opt-in rather than opt-out?
There are a couple of open questions, e.g. * What would the syntax be? * What about extern functions? * What would the performance impact be? Could it be mitigated?
One more point: what about nogil functions? They can, in theory, raise exceptions, but they almost never do in practice.
I think feels like it should be orthogonal, I wonder what the overhead of this check really is in practice... Given that the default for return type annotations is exception propagation
(i.e. Python semantics) now, mixing that into a nogil function means that the caller would almost always check for exceptions needlessly. And we do not currently have a way to say "no exception return value" to get rid of that check. That's something we'd need, especially if we change the default.
Yeah, that's what I meant about the syntax question.
Stefan _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
participants (2)
-
Robert Bradshaw -
Stefan Behnel