Alex Willmer

Results 363 comments of Alex Willmer

> Of note, imports inside try/except and with blocks are never imported lazily. Both structures commonly handle import-related errors: for example, when detecting available or compatible modules > -- https://www.hudsonrivertrading.com/hrtbeat/inside-hrts-python-fork/

Signals/conditions on target host that may be of use - Python 3, attempt to import a known Python 2 module name (#265) - Import _by_ a stdlib module, e.g. https://github.com/mitogen-hq/mitogen/blob/db63dd1def114b729d87966f76e013d1478264ab/mitogen/core.py#L1336-L1338...

> This package includes lists of all of the standard libraries for Python 2.6 through 3.14. > > IMPORTANT: If you're on Python 3.10 or newer, you probably don't need...

`foo` being a builtin module does not imply `foo.bar` will also be builtin. Atleast since Python 3.12 ```pycon >>> import _imp, sys >>> sys >>> sys.monitoring >>> _imp.is_builtin('sys'), _imp.is_builtin('sys.monitoring') (-1,...

Possible small speedup (benchmarked on CPython 3.14) ```console $ python -m pyperf timeit -s "import _imp" "_imp.is_builtin('sys')" ..................... Mean +- std dev: 234 ns +- 2 ns $ python -m...

Idea: controller sends list of what it considers (top level) stdlib modules, so children can skip requesting them.

Presence/status of `__main__` changed over time ```console $ ... python2.4 -c "import imp, sys; print('%r, %r' % ('__main__' in sys.builtin_module_names, imp.is_builtin('__main__')))" WARNING: image platform (linux/amd64) does not match the expected...

https://blog.pypi.org/posts/2025-11-26-pypi-and-shai-hulud/

Some experimentation to reduce _first_stage(), so far saved 200ish bytes https://github.com/dw/mitogen/compare/master...moreati:first-stage-golf