How about just putting a reference to the C module into the instances of the shadow class? import PyGridc #c library functions class MyClass: def __init__(self) ... self.PyGridc = PyGridc ... Then the PyGridc module won't be unloaded until all instances of MyClass are gone.