Tags

imports

4 posts

  • Swapping Two Imports Moved 5.5 ms to a Different Module

    Importing logging before asyncio moves 5.5 ms from asyncio's line to logging's. The program does the same work. The cumulative column charges whoever got there first.

  • lazy import Moved 26.8 ms and Removed None of It

    A lazy import of asyncio costs no measurable time and no modules at startup. Read the name once and 26.4 of the 26.8 ms come back. Deferral is not removal.

  • Type Hints at Run Time

    Annotations cost nothing per call and everything at import. Reading __annotations__ takes 24 ns; resolving the same class with get_type_hints takes 3.4 µs, 140x more.

  • What import Actually Does

    Importing asyncio costs 21.9 ms and pulls in 100 modules. Importing email costs 0.1 ms and pulls in one. Granularity predicts import cost; size does not.

Arrow keys to move, Enter to open.