>How can I force to unload the old module so PyImport_Import function loads >the new contents of the file? Have you tried PyImport_ReloadModule()? Try it right after importing the module the second time.