[C++-sig] Boost.Python: Callbacks to class functions

Paul-Cristian Manta paulc.mnt at gmail.com
Tue Aug 2 08:13:46 CEST 2011


On Tue, Aug 2, 2011 at 8:24 AM, Jim Bosch <talljimbo at gmail.com> wrote:

>
> Hmm.  That might mean you need to do a big design change; while it often
> works, one really isn't supposed to rely on __del__ being called when a
> Python object first could be garbage-collected - when cycles are involved,
> Python doesn't even guarantee that it will ever call __del__.  It sounds
> like you'd be much better off with a named destructor-like method that would
> be called explicitly when you want to remove an object from the game.
>
>
I am aware of that. :) Still, I'd like to leave it only as a last resort, I
don't like complicating the API (who does? :P ). If I get rid of the strong
reference that the `EventManager` has over the callback, there will be no
cycles. My dependency graph would look something like this:

► http://i.imgur.com/wkxUn.jpg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20110802/ec837446/attachment.html>


More information about the Cplusplus-sig mailing list