[Numpy-discussion] reload and f2py

Fernando Perez fperez.net at gmail.com
Tue Sep 26 11:46:14 CDT 2006

On 9/26/06, George Nurser <gnurser at googlemail.com> wrote:
> I'm running Python 2.3.5 with recent SVN f2py.
> Suppose I import an extension I have built with f2py. Then, if I edit
> the fortran and recompile the extension, I cannot use reload to use
> the modified version within the same Python session.
> I believe this is an problem with Python, that reload doesn't work
> with externally compiled extensions.

As far as I know, you are correct.

> Is this something that can be changed in future versions of Python, or
> is it an inherent problem? For editing and recompiling within an
> ipython session is quite a good way of getting the fortran code to
> work, leaving aside any problems in doing the f2py interfacing.

Unfortunately due to this limitation, I just restart ipython when I
need to reload extension code.  I'd be thrilled to know if there is
any easy workaround.

It's worth noting that weave is in this regard extremly
ipython-friendly: since the name of the extension it loads is a hash
of the source, /any/ change to the source results in a newly named
extension being built and loaded.  So while you get a bit of memory
bloat by keeping the old, unused extensions around, the net
interactive effect is that 'reloading works' for weave-generated code.
 One more reason why I think weave is the best thing since toasted



More information about the Numpy-discussion mailing list