[C++-sig] Re: python binding problems

David Abrahams dave at boost-consulting.com
Sun Dec 28 14:02:11 CET 2003


"Dusty Leary" <dleary at ttlc.net> writes:

>>
>> Pass ptr(x) instead of x if you don't want the foo copied.
>>
>
> Thanks very much.
>
> Is there a way to specify this as the default behavior for a type, maybe via
> the to_python handlers or whatever?

Nope.

> Basically, something so that whenever I call python with a foo*, it will do
> the pointer_wrapper<> thing...

Sorry, it's explicit for a reason: passing by-raw-pointer is unsafe.
The original C++ object's lifetime can end while the Python object is
still alive, and usage of the Python object thereafter can crash the
interpreter.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list