toki doki skrev:
> As for me not understanding c++, however, please note that:
> 1- this was meant as a minimal bug code stripped out of any context
> 2- cython doesn't allow (AFAIU) stack-allocated c++ object as members
> of a python extension class. Therefore, if one wants to create a
> Python class wrapping a vector, I think one has to write things like
> "self.pVect=new vector<xxx>"  (and of course add the appropriate "del
> self.pVect" in the "__dealloc__" method of the class. Of course, I am
> still trying to understand how the c++ mode of cython works, therefore
> I might be wrong.
>   
Out of curiosity, what happens if allocation fails, and C++ raises 
std::bad_alloc? In C++ if you have used new and delete outside 
constructors, it might give you memory leaks. In Cython I suppose the 
C++ exception goes uncaught, so the program just crashes. I would use 
Python lists or NumPy arrays instead.

Sturla





_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to