/
githubmirror
/
rich
Обзор
Документация
Войти
/
githubmirror
/
rich
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tools/profile_pretty.py
23 строки
488 B
Will McGugan
version bump
20 окт 2020, 17:03
20 окт 2020, 17:03
cbac633
Код
Авторство
О чём код?
import json import io from time import time from rich.console import Console from rich.pretty import Pretty console = Console(file=io.StringIO(), color_system="truecolor", width=100) with open("cats.json") as fh: cats = json.load(fh) console.begin_capture() start = time() pretty = Pretty(cats) console.print(pretty, overflow="ignore", crop=False) result = console.end_capture() taken = (time() - start) * 1000 print(result) print(console.file.getvalue()) print(f"{taken:.1f}")