[C++-sig] Whats going on under the hood?
Roman Yakovenko
roman.yakovenko at gmail.com
Thu Jan 18 06:21:37 CET 2007
On 1/18/07, David Sveningsson <eXt at sidvind.com> wrote:
> I want to understand how python/boost handles the memory.
>
> Take a look at the following code:
>
> void add(Base& e){
> list->add(e); // Permanently stores the object
> }
>
> BOOST_PYTHON_MODULE(Foo){
> def("add", &add);
>
> class_<Base>("Base")
>
> ;
> }
>
> and this:
>
> class Derived (Foo.Base):
> pass
>
> add(Derived())
>
> What happens when this code is run? What happens when the python scope
> ends? May I safely use the reference in C++? Should I delete the
> reference afterwards? What happens if I delete the reference, does it
> delete memory allocated from python too?
Did you read tutorials?
http://boost.org/libs/python/doc/tutorial/doc/html/python/functions.html#python.call_policies
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
More information about the Cplusplus-sig
mailing list