[C++-sig] Inconsistency with Boost.Python code
Robert
rcdailey at gmail.com
Thu Oct 9 18:24:50 CEST 2008
Hi,
Suppose the following C++ Boost.Python code below. Note that I am
embedding the python interpreter to execute python scripts from C++:
using namespace boost::python;
object imported( import( "sys" ) );
dict sysdict( imported.attr( "__dict__" ) );
list syspath( sysdict["path"] );
syspath.append( "C:\testing" );
When I do the following python code in a script that I load after
calling the code above, the output shows that "C:\testing" is not
present in the list of paths:
import sys
print sys.path
However, when I do the Boost.Python code below, it works perfectly fine:
import( "sys" ).attr( "path" ).attr( "append" )( "C:\testing" );
Both should do the same thing, however one works and one does not.
Somewhere a copy seems to be getting created, when according to my
research they should be reference counted. Can anyone explain the
reasoning for this?
More information about the Cplusplus-sig
mailing list