[C++-sig] boost.python: when does python call c++ destructors?
seefeld at sympatico.ca
Fri Feb 29 15:16:48 CET 2008
Sebastian Walter wrote:
> Ok, I figured out what I have been missing. Actually it are two things
> 1) C++ automatically defines a standard copy constructor when it is not
> manually defined.
> 2)In Python the expression "c = a*b" first computes a*b where a temporary
> object tmp is created. But instead of using this tmp object and give it the
> name c, Python does the following:
> The copy constructor with tmp as argument is called and this new copy
> is "given the name" c.
This is not quite accurate. Python doesn't know about temporaries and
copy-construction, as it always uses references.
It is your own definition of operator* that requires the temporary.
...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig