alexdelorenzo / strs Goto Github PK
View Code? Open in Web Editor NEW🧵 Easy string tools for the shell
Home Page: https://alexdelorenzo.dev
License: GNU Affero General Public License v3.0
🧵 Easy string tools for the shell
Home Page: https://alexdelorenzo.dev
License: GNU Affero General Public License v3.0
Here's the issue:
$ 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:
$ time echo "$(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
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.