37 lines
1.4 KiB
Markdown
37 lines
1.4 KiB
Markdown
# philosophy
|
||
|
||
## classes
|
||
- compositional
|
||
- only init manipulates the object
|
||
- no inheretance
|
||
- functions return a clone of the object with primary data object cloned and manipulated
|
||
|
||
## other
|
||
- heavy inference from type hints
|
||
- library-ize everything
|
||
- thin CLI wrapper as stand alone file
|
||
- pyproject setup only
|
||
- deveopment branch with pyenv to source into shell for development
|
||
- data oriented with classes being simplest data conainers with helper functions
|
||
|
||
## imports
|
||
Files with an _prefix_ underscore are, by convention, imported in `__init__.py`. For example,
|
||
|
||
```python
|
||
from ._rgb_ import *
|
||
```
|
||
|
||
This will import all of the functions from `_rgb_` into the module’s name space. So If `_rgb_` contains a function `interpolatePoint` you can reference it by `PythonModuleDemo._rgb_.interpolatePoint` or more simply `PythonModuleDemo.interpolatePoint`. Since this module is intended to provide a swath of functionality I wanted to provide the user with the simplest method of access.
|
||
|
||
The reason all files end with a _suffix_ underscore is to avoid any name collisions with python standard Library. For instance I have a file called `_math_.py`. If it were only called `math.py` it would collide with python standard Library when doing `import math`.
|
||
|
||
# import time
|
||
```bash
|
||
λ 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
|
||
```
|