If char const* is passed to objecjt.attr(), it uses
PyObject_GetAttrStrng() or PyObject_SetAttrStrng(). If object is
passed to objecjt.attr(), it takes the object as a Python string
object and uses PyObject_GetAttr() or PyObject_SetAttr().

If attr() behaves like this, it can be useful when there are lots
of objects which you know have the same attribute name. You can save
time by first making a boost::python::object and passing it to every
object's attr() inside a loop.

I just made a bit of modification to boost:python locally and did a
quick test, like

test 1:

for(int i = 0; i < n; ++i)
{

omain.attr(attrname) = 444; attrname is a char const*

}

test 2:

for(int i = 0; i < n; ++i)
{

object o = omain.attr(attrname); attrname is a char const*

}

test 3:

for(int i = 0; i < n; ++i)
{

omain.attr(oaaaa) = 444; oaaaa is boost::python::object that represents a string

Add Comment

This ticket has been modified since you started editing. You should review the
other modifications which have been appended above,
and any conflicts shown in the preview below.
You can nevertheless proceed and submit your changes if you wish so.