No description
Ethan Dalool
b288cca519
I was inspired by the idea of "making impossible states impossible" and using a data model that accurately represents what we intend for it to represent. Instead of storing the path as a string where "it's a string but actually you're supposed to know that the parts between os.seps are different parts and the first one is special and...", we can use a data model that directly says that. Storing the path as a tuple of (Drive, Part, Part) helps me focus on the semantics of the Path as a collection of parts joined by the os.sep. Furthermore, storing the path as a string made some operations slow. Every time we call one of the os.path functions with a string, it has to do a lot of normalization and edge-case handling even when we know it wouldn't be needed. By storing the path as a tuple, we can instantly get the drive name, parent dir name, and basename without asking os.path to split it for us every single time. It also makes relative path / common ancestor checks a lot easier to understand. Fewer operations need to go into the slow functions. |
||
---|---|---|
voussoirkit | ||
CONTACT.md | ||
LICENSE.txt | ||
pypi_upload.bat | ||
README.md | ||
setup.py | ||
voussoirkit_logo.svg |
voussoirkit
This is a collection of tools that I use often and import into my other projects.
Install
pip install voussoirkit
Mirrors
https://github.com/voussoir/voussoirkit