pythonic way to optimize access to imported value?

Brian Quinlan brian at sweetapp.com
Mon Nov 18 04:04:43 EST 2002


Bengt wrote:
> IOW, IMO there ought to be a way to do a temporary
global-side-effect-free
> import and delete all traces of its having been done -- without
restarting
> the interpreter or invoking a second interpreter instance.

Does that involve unloading a dynamically imported library? If so, you
will have to figure out how to do that in a cross-platform manner and
without breaking existing Python extensions.

Here are some other issues:
1. What happens if two "throwaway" imports of the same module happen at
   once?
2. What happens if the extension module modifies global state?
3. What happens if the extension module causes external entities to 
   hold references to its objects?

Cheers,
Brian





More information about the Python-list mailing list