Revision 1 as of 2002-12-10 20:30:26

Clear message

Memory consumption

In general, a wrapped C++ object with a corresponding Python object is the size of:

You can see this in boost/python/object/instance.hpp. Most Python objects are represented by instance<value_holder<T> >, for some C++ class T.

All the code for implementing C++ object wrappers is in libs/python/src/object/class.cpp. Instance dictionaries are created only "on demand", the first time the instance's dict attribute is accessed (see instance_get_dict).

If your C++ data structure contains pointers or smart pointers, you can arrange for Python objects to be created which only embed those pointers (instance<pointer_holder<Ptr> >). These Python objects will be in existence only as long as your Python code holds a reference to them.

Unable to edit the page? See the FrontPage for instructions.