4.7 KiB
4.7 KiB
Important Files
├── bashrc_defl.sh |
├── bin |
│ ├── ddwatch.sh |
│ └── deflMergeDevToMain.sh |
├── defl |
│ ├── *_.py |
│ ├── _*_.py |
│ ├── _path/ |
│ └── thirdParty/ |
│ └── * |
├── LICENSE.GPL |
├── pyproject.toml |
├── README.md |
├── scripts/ |
│ └── setup.sh |
└── tests/ |
└── test_*.py |
Pragdim
- Data oriented with classes being simplest data conainers with helper functions
security
- Minimal use of PyPi dependencies to reduce security overhead
- Use system tools installed via systempackage manager
- Safer but nothing is perfect
Dockernetnsnetwork namespace isolation- When installing packges go to github page and look for an explicit
pip install ...to avoid typosquatting due to typos. - Don't trust PyPi
- "
Starjackingis linking a PyPi package to an unrelated repository on GitHub that has plenty of stars, suggesting popularity. [...] there is no validation of these links on PyPi [...]." (source)
- "
Classes
- Dataclass with functional programming
Compositional
No Inheritance
- Limited use of mixins.
- No super classing.
- The inheritence hierarcy is a single level.
- No object has a parent.
- https://doc.rust-lang.org/book/ch18-01-what-is-oo.html
-
Inheritance has recently fallen out of favor as a programming design solution in many programming languages because it’s often at risk of sharing more code than necessary. Subclasses shouldn’t always share all characteristics of their parent class but will do so with inheritance. This can make a program’s design less flexible. It also introduces the possibility of calling methods on subclasses that don’t make sense or that cause errors because the methods don’t apply to the subclass. In addition, some languages will only allow single inheritance (meaning a subclass can only inherit from one class), further restricting the flexibility of a program’s design.
-
Manipulation
- Dot Chaining
- Most functions return
selfso many functions can run on one line. - See
Run()class. - Example:
Run(['ls']).run(out=F, err=T).assSuc().json()Run(['ls'])creates the object.run(out=F, err=T).assSuc()both returnself.json()returns a dict
- Most functions return
clone()function returns a copy of the object with primary data object duplicated and altered- see
Dath()class.
- see
set/get- See
Find()class.
- See
Type Hints
- inference
Module
library-ize everything
- Thin CLI wrapper as stand alone file
Setup
scripts/setup.sh
pyproject.toml
Files
- Always use underscore to avoid namespace collision
- Example:
import mathis a python stdlib module.- If a file,
math.py, exists in the source directory it will cause collision. - Instead create
math_.pyto subvert the issue.
- Example:
_*_.py(i.e._path_.py)- This is always import and casted into the modules namespace.
- Imported in
__init__.py - Example:
- there is a Class called
Dathinsrc/defl/_path_.py - You can refer to it using
from dath._path_ import Dathor simplyfrom defl import Dath
- there is a Class called
*_.py(i.e._path_.py)- These are not automatically imported.
- One must import them explicitly.
- Example:
from dath.mpv2_ import Mpv
Branching
- Deveopment branch with env to source into shell for development
defl/deflDevbin/deflMergeDevToMain.sh
Unit Tests
Import Time
λ timeRepeat.py - -c 500 -- python -c ''
0.021840
λ timeRepeat.py - -c 500 -- python -c 'import defl'
0.161801
λ python -c 'print(0.161801/0.021840)'
7.4084706959706965