[SciPy-dev] reimplementation of lfilter

David Cournapeau david@ar.media.kyoto-u.ac...
Wed Sep 23 20:26:15 CDT 2009

Sturla Molden wrote:
> The 
> advantage is that you get C code that don't have to do error checking 
> everywhere.

Really, this is a big disadvantage. In C, you have to check error codes.
Anything which gives the illusion you can get away with it is wrong
IMHO. Technically,  setjmp/longjmp are also problematic for many reasons
(often the same as C++ exceptions: it is difficult to get right). At
least with goto you can often understand what's wrong - not so much with
longjmp/setjmp - if the error handling is too complicated to handle with
simple goto, then the code itself is too complicated. If you need to
handle deeply nested errors, then using the C API for python exception
is good enough.

I agree we are not as good as we should in numpy for error handling at
the C level, but I think it boils down to not having a unified error
handling (that is -3 may mean could not allocate in one function, and
could not convert the argument to something in another). But that can be
solved with a unified set of error codes and associated strings + a
simple log system (that's how sndfile does it for example, and I really
like it).



More information about the Scipy-dev mailing list