snu-quiqcl / qiwis

QuIqcl Widget Integration Software
MIT License
5 stars 2 forks source link

Why do we even consider 'sys.modules' in 'swift.swift._add_to_path'? #113

Closed BECATRUE closed 1 year ago

BECATRUE commented 1 year ago

Discussed in https://github.com/snu-quiqcl/swift/discussions/111

Originally posted by **BECATRUE** March 23, 2023 I have a question about `_add_to_path()` function in `swift.swift` module. The function is as below: ```python @contextmanager def _add_to_path(path: str): """Adds a path temporarily. Using a 'with' statement, you can import a module without changing sys.path. Args: path: A desired path to be added. """ old_modules = sys.modules sys.modules = old_modules.copy() old_path = sys.path sys.path = old_path.copy() sys.path.insert(0, path) try: yield finally: sys.path = old_path sys.modules = old_modules ``` In the function, we change only `sys.path`, but why do we even care about `sys.modules`? I think it is not neccessary to consider `sys.modules`.

Feature you want to implement

I just want to remove the part about sys.modules.