[SciPy-dev] reimplementation of lfilter
Wed Sep 23 11:25:46 CDT 2009
On Thu, Sep 24, 2009 at 12:07 AM, Sturla Molden <firstname.lastname@example.org> wrote:
> David Cournapeau skrev:
>> It can be a full rewrite, but still should be sent as patches. If I am
>> the one to review, I would prefer this way. That's especially
>> important to track regressions.
> Well.. I didn't intend this for inclusion in SciPy, at least not in the
> beginning. I needed it for some neuroscience software I am writing.
>> It is a fundamental problem of C++. Different compilers do not
>> propagate exceptions the same way, and that's a problem when different
>> compilers are involved (happens easily when the C and C++ compilers
>> are not the same, for example). That has been a problem on every new
>> platform I have tried to port numpy and scipy to.
> Does this mean we cannot use g++ to compile extensions at all, when
> Python VM is compiled with MSVC?
Oh, you certainly *can*, as we can use gcc to compile extensions
against python built with MS compiler. But there are limitations -
with C, those limitations are known, with C++, they become atrocious
once you use the C++ runtime (RTTI, exception, etc...). I had to debug
some stuff in sparsetools on windows 64 bits a few days ago, and this
was horrible because the exceptions are lost between DLL.
> I don't like the complexity of C++. But it has some advantages over C
> for scientific computing; notably STL containers, templates for
> generics, the std::complex<> type, and so on.
For basic templates, the .src stuff is good enough. For complex, yes,
that's a bit of a pain, although you could use the C99 complex type if
you only care about modern C compilers in your own extension.
> I personally like exceptions because they remove the need for lot or
> error checking.
I call this a disadvantage :) And having exceptions in a language
without gc causes more trouble than it worths IMHO. Exception-safe C++
is incredibly hard to do right.
> In C, we can achieve almost the same effect using
> setjmp/longjmp. Is that bad style as well?
The standard way to handle errors in C code using the python API is
goto. It works well, and if you need to jump several calls, you can
always use python exception mechanism.
More information about the Scipy-dev