-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Performance] Using rich.console.Console() takes multiple seconds #1104
Comments
Console constructor does next to nothing. What you are timing is importing a 20 or so Python files, which takes 70ms or so on my system. I'd suggest looking in to why it is slow to import things on your system. Try the following switch to see you are importing something you don't expect.
|
It looks like the bulk of the time is importing
python3 -X importtime -c 'from rich.console import Console; Console()'
|
That's interesting. pydoc is relatively quick here. Since I can't reproduce it. You might want to profile it with scalene, or other profiler. It could be related to your installation of Python, but let me know if there is something I could do on the Rich side to speed up the import. One option would be to make the import lazy, so pydoc isn't imported if you don't use the pager. |
I'll make the import lazy. Couldn't hurt. But let me know if you figure out why it is slow for you. |
I've tracked the root cause of this to something company, internal. Normal
pydoc loads fast, internal pydoc takes 2-3 seconds.
Thanks in any case for making the import lazy, lots of tools that I use
make use of Rich, and import pydoc by extension, and I cannot reorder $PATH
to get the "fast" Python on my workstation, unfortunately.
*Zach Riggle*
…On Thu, Mar 11, 2021 at 3:37 PM Will McGugan ***@***.***> wrote:
Closed #1104 <#1104>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1104 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA3IGFCJRJSUJ5L26PHTCLTDEZ3PANCNFSM4Y2FIYDQ>
.
|
Describe the bug
When using
rich.console
, the startup time of my application increases greatly.You can see this easily by using
hyperfine
to benchmark the application.To Reproduce
First,
brew install hyperfine
or install Hyperfine in some other way. It takes 80ms for the Python3 interpreter to start, but 1.6s to runrich.console.Console()
. This is an unacceptable performance penalty for command-line utilities, and for simple scripts incurs a 20x performance penalty.Hyperfine Benchmark Results
Platform
macOS
$ sw_vers
ProductName: macOS
ProductVersion: 11.3
BuildVersion: 20E5172h
Diagnose
I may ask you to cut and paste the output of the following commands. It may save some time if you do it now.
python3 -m rich.diagnose
python3 -m rich._windows
pip3 freeze | grep rich
Did I help?
If I was able to resolve your problem, consider sponsoring my work on Rich, or buy me a coffee to say thanks.
The text was updated successfully, but these errors were encountered: