[C++-sig] reloading modules written with Boost.Python

Christoph Groth cwg at falma.de
Wed Sep 26 09:48:21 CEST 2007


Dear group,

I've created a simple module with Boost.Python which provides a single simple
function.  Importing that module into python and executing the function works.

It would be nice to be able to change the function, recompile the module, and
`reload(module_name)' it in python without restarting the interpreter.  This,
however does not work.  Python says it has reloaded the module but when I
execute the function it is still the old one:

****************************************************************
$ python
Python 2.4.4 (#2, Aug 16 2007, 02:03:40) 
[GCC 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rrn
>>> rrn.test()
old function
>>> # now I recompile rrn.so
... 
>>> reload(rrn)
<module 'rrn' from 'rrn.so'>
>>> rrn.test()
old function
>>> 
$ python
Python 2.4.4 (#2, Aug 16 2007, 02:03:40) 
[GCC 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rrn
>>> rrn.test()
new function
****************************************************************

I'm using the libboost packages from Debian testing (Version 1.33.1-10).

I'm grateful for any hints

Christoph




More information about the Cplusplus-sig mailing list