deleting global namespaces

mdvorak at ninell.cz mdvorak at ninell.cz
Fri Feb 4 18:10:05 EST 2000


Hi,

I've got an advanced question I am not able
to find answer for.

I'm embedding Python in a multimedia engine
and I really like what Python does with global
namespace when it imports new module. It's great
that it creates new global namespace for each
module so that it is impossible for the module
to access real global namespace in any way.

I would like to use this feature to divide one
application into more independent components.

My idea is that each component will sit in
a module and there will be some functions which
will take care of starting the module and performing
clean up upon exit.

But the problem is there is no way to force Python to
delete module together with all variables/functions
which exist in its global namespace - that is
I cannot perform any clean up. Upon exit I would
have to go through all global objects and delete
them explicitly, but I cannot do this, because
throughout the application one module can be
started multiple times and each time it has to
run like it was started for the first time.

I guess my idea is not possible because of optimizations
Python performs on modules to work with them as
fast as possible, but I really need to divide
application to more parts each with its own
global namespace.

Is there some workaround (including patches to the
source code) to do this with modules or some other
way to create and delete new global namespace?

I do not want to create new subinterpreter for each
application's component because I want all components
to use the same built in modules and I want to pass
an application-wide dictionary between each component's
namespace.

Thanks very much for any advice.

Regards,
Martin


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list