Skip to content

Instantly share code, notes, and snippets.

@meooow25
meooow25 / fast_input.py
Last active November 12, 2018 08:34
Super fast input for Python. Can be made faster by sacrificing ease of use and accessing the tokens directly instead of using the ns, nf, ni functions.
def init_input():
import os
from sys import stdin
it = iter(os.read(stdin.fileno(), 10 ** 9).split())
return lambda: next(it).decode(), lambda: int(next(it)), lambda: float(next(it))
ns, ni, nf = init_input()
some_string = ns()
some_int = ni()
some_float = nf()