Improve performance of _get_zipimporters
_get_zipimporters can call isinstance millions of times when
running pylint's import-error checker on a codebase like yt-dlp.
Checking for None first avoids the overhead of invoking isinstance.
Closes pylint-dev/pylint#9607.
diff --git a/astroid/interpreter/_import/spec.py b/astroid/interpreter/_import/spec.py
index 469508d..59546a0 100644
--- a/astroid/interpreter/_import/spec.py
+++ b/astroid/interpreter/_import/spec.py
@@ -341,7 +341,7 @@
def _get_zipimporters() -> Iterator[tuple[str, zipimport.zipimporter]]:
for filepath, importer in sys.path_importer_cache.items():
- if isinstance(importer, zipimport.zipimporter):
+ if importer is not None and isinstance(importer, zipimport.zipimporter):
yield filepath, importer