Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Print sync

  • First let's see a few small and useless examples.
  • In this example we wait and print sequentially. No async here.
import time

def say(text, sec):
    time.sleep(sec)
    print(text)

def main():
    start = time.monotonic()
    say("First", 2)
    say("Second", 1)
    end = time.monotonic()
    print(f"Elapsed: {end-start}")

main()

First
Second
Elapsed: 3.0015416080132127