4 ms·
I’ve found Python is just fine performance-wise for CLI tools. What bad experiences have you had with it? I’ve mostly used click.
by tcbasche 5y ago
I’ve found Python is just fine performance-wise for CLI tools. What bad experiences have you had with it? I’ve mostly used click.
- watermelon0 5y agoPython interpreter by itself is fast, it spawns in a few milliseconds, but it can slow to a crawl if you need libraries, and easily take a few seconds. However, situation is similar with nodejs.
- IshKebab 5y agoStartup time is very slow. I just tested on my system and cold startup was 1 second (!) and hot 180ms. Vs 80ms and 64ms for Node. Also it obviously depends what your CLI tool is doing. Just because something is a CLI tool doesn't mean it doesn't do much stuff and therefore performance doesn't matter. For example Scons is a CLI tool. It's a build system written in Python. Everybody abandoned it because it was dog slow. Mercurial is a CLI tool. It's a VCS written in Python. Most people have abandoned it partly because it is slow (and partly because Github exists). You can read about Mercurial's troubles with Python performance here: https://www.mercurial-scm.org/wiki/OxidationPlan https://www.mercurial-scm.org/wiki/OxidationPlan > Performance is a significant pain point with Python. There are multiple facets to the performance problem: > * Startup overhead > * General performance overhead compared to native code > * GIL interfering with parallel execution > It takes several dozen milliseconds to start a Python interpreter and load the Mercurial Python modules. If you have many extensions loaded, it could take well over 100ms just to effectively get to a Mercurial command's main function. Reports of over 250ms are known. While the command itself may complete in mere milliseconds, Python overhead has already made hg seem non-instantaneous to end-users.
- miohtama 5y agoHow much difference does 180 ms vs. 64 ms make for your use case?
- mst 5y agoIn scripts designed to be run directly at a bash prompt by humans, the difference would absolutely be noticeable.
- IshKebab 5y agoIt is definitely noticeable even when you run a command once. But it really becomes a problem when your command is run lots of times as part of some other system. For example if you're using Python to process a lot of files via Make (something my work's build system does unfortunately) then it can end up costing 10s of seconds which is kind of insane.