Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Jason H Newsgroups: comp.lang.python Subject: Re: Lazy Imports -- I Like This Idea Date: Tue, 14 Apr 2026 22:16:56 -0000 (UTC) Organization: A noiseless patient Spider Lines: 27 Message-ID: <10rmeco$ftk4$1@dont-email.me> References: <10q22pv$2f060$2@dont-email.me> <10q7n78$atfj$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 14 Apr 2026 22:16:56 +0000 (UTC) Injection-Info: dont-email.me; posting-host="c6de2afe4b942814fe87ca56102a60d6"; logging-data="521860"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rQ3An1hklCezaqYUycMTdf8Id/FEoK8g=" User-Agent: PhoNews/3.13.3 (Android/16) Cancel-Lock: sha1:3xP1ipFSWU6MBUuJQioZlYgQB4c= In-Reply-To: <10q7n78$atfj$2@dont-email.me> Xref: csiph.com comp.lang.python:197764 On 28/03/2026 04:59, DFS wrote: >On 3/25/2026 9:40 PM, Lawrence D’Oliveiro wrote: > >> So Python 3.15 will introduce a new, “lazy” import mechanism >> . >> >> So far I have done one script where I moved an import into the >> function where it was used, instead of doing it globally; this reduced >> the script startup time from around 1.5 seconds down to about a >> quarter second. >> >> “Lazy” imports would avoid the need for such workarounds, while >> keeping all imports together so they can be found more easily. > > >Faster startup is nice, but lazy importing doesn't reduce total runtime >of the program, right? > Perhaps. Perhaps not. If the conditions for the import to run at all are never met, total execution time can be faster. Also, there is a history of psychology and smoke and mirrors in the world of software. -- -- A PICKER OF UNCONSIDERED TRIFLES