[C++-sig] When You Create an Python Object Using Boost.Python, How Do You Find Out Its Name?

Nat Goodspeed ngoodspeed at solidworks.com
Mon Jul 9 23:24:09 CEST 2007


> -----Original Message-----
> From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org]
On
> Behalf Of Lawrence Spector
> Sent: Monday, July 09, 2007 5:16 PM
> To: Development of Python/C++ integration
> Subject: Re: [C++-sig] When You Create an Python Object Using
> Boost.Python, How Do You Find Out Its Name?
> 
> is there a way to add it to the dict without making a copy,
> but instead having foo be a reference to the instance of MyClass()?

[Nat] boost::python::object is a C++ wrapper around a classic-C Python
reference pointer. Once you've instantiated a Python-compatible object
and captured its reference pointer using boost::python::object, I would
expect you to be able to copy the boost::python::object as needed (e.g.
into a dict) with every copy of the boost::python::object value
referencing the same MyClass instance.

If that's not what you're seeing, maybe a complete, minimal code example
would help.



More information about the Cplusplus-sig mailing list