You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
lazy import of _sysconfig in Lib/ctypes/__init__.py is eager on android and cygwin #158684
(this was found using some recent static analysis capabilities I added to pyflakes -- it searches for lazy imports which are used at the module scope within the module)
$ git grep -El '^lazy (from|import)' -- '*.py'| xargs pyflakes 2> /dev/null | grep ' eager use'Lib/ctypes/__init__.py:560:23: eager use of lazily imported '_sysconfig' from line 7Lib/ctypes/__init__.py:562:23: eager use of lazily imported '_sysconfig' from line 7Lib/test/test_lazy_import/data/basic_used.py:3:1: eager use of lazily imported 'basic2' from line 1Lib/test/test_lazy_import/data/lazy_import_pkg.py:2:5: eager use of lazily imported 'test' from line 1
(the latter two are test data which makes sense to ignore)
Hmm, is there anything we can actually do about this? It seems that we do need _sysconfig eagerly on those platforms. I suppose we could set up a __getattr__ to lazily evaluate it, but that might be overkill and/or have some unintended side effects.
Isn't this lazy import still correct for other platforms? I don't think it's an issue per se though? many imports can be lazy because a single function uses them but if no one is using the function we still have a lazy pending import so I don't understand why this should be removed.
Yes, if the import is only eagerly used on some platforms then it's fine for it to be a lazy import. This isn't a bug.
Edit: I don't see a test that checks the import is lazy in the ctypes tests though, perhaps there should be one for the platforms where this is currently lazy?
Activity
ZeroIntensity commentedon Oct 4, 2026
Hmm, is there anything we can actually do about this? It seems that we do need
_sysconfigeagerly on those platforms. I suppose we could set up a__getattr__to lazily evaluate it, but that might be overkill and/or have some unintended side effects.picnixz commentedon Oct 4, 2026
Isn't this lazy import still correct for other platforms? I don't think it's an issue per se though? many imports can be lazy because a single function uses them but if no one is using the function we still have a lazy pending import so I don't understand why this should be removed.
DavidCEllis commentedon Oct 4, 2026
Yes, if the import is only eagerly used on some platforms then it's fine for it to be a lazy import. This isn't a bug.
Edit: I don't see a test that checks the import is lazy in the ctypes tests though, perhaps there should be one for the platforms where this is currently lazy?
picnixz commentedon Oct 4, 2026
Yes, so IMO we don't need to change anything.