You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ time python -c "import sys, emoji, fire, more_itertools"
real 0m0.121s
user 0m0.105s
sys 0m0.019s
$ time python -c "import fire"
real 0m0.106s
user 0m0.086s
sys 0m0.023s
$ time python -m strs isalnum 1
real 0m0.146s
user 0m0.115s
sys 0m0.033s
Start up time, at minimum, will have a ~100ms duration on a NVMe drive with hot caches.
This doesn't really matter when using strs on the command line, but when you're writing scripts with a lot of string manipulation, it can be relatively slow:
$ timeecho"$(str repeat 5 test| str join :| str split :| str nth 1 2 3 | str join ''| str col 1)"test
real 0m0.234s
user 0m0.861s
sys 0m0.168s
Potential solutions
Using click can shave off ~34ms from start up:
$ time python3 -c "import click"
real 0m0.072s
user 0m0.059s
sys 0m0.016s
Nuitka, in general, can give a 4x execution speed up, which can result in a ~28ms to ~37ms start up time. Mypyc and Nuitka don't support Python 3.10, but Numba does and so does Cython. I have to look further into PyOxidizer and PyO3.
It would also help to profile it and see exactly what's going on during start up. I think the script might just be hitting the disk heavily with imports that are spread across many files. Dynamically loading dependencies might help in that case, or inlining.
Or, instead of relying on pipes to pass strings through different manipulation commands, strs can use Fire's command chaining feature, or click's command chaining feature. The CLI API might have to change, and the input handling might need to be refactored, in order for command chaining to work nicely with the current code and how it's structured.
That, or I can just port it to Rust.
The text was updated successfully, but these errors were encountered:
Problem
Here's the issue:
Start up time, at minimum, will have a ~100ms duration on a NVMe drive with hot caches.
This doesn't really matter when using
strs
on the command line, but when you're writing scripts with a lot of string manipulation, it can be relatively slow:Potential solutions
Using
click
can shave off ~34ms from start up:Nuitka, in general, can give a 4x execution speed up, which can result in a ~28ms to ~37ms start up time. Mypyc and Nuitka don't support Python 3.10, but Numba does and so does Cython. I have to look further into PyOxidizer and PyO3.
It would also help to profile it and see exactly what's going on during start up. I think the script might just be hitting the disk heavily with imports that are spread across many files. Dynamically loading dependencies might help in that case, or inlining.
Or, instead of relying on pipes to pass strings through different manipulation commands, strs can use Fire's command chaining feature, or click's command chaining feature. The CLI API might have to change, and the input handling might need to be refactored, in order for command chaining to work nicely with the current code and how it's structured.
That, or I can just port it to Rust.
The text was updated successfully, but these errors were encountered: