Brain-plasma

Latest version: v0.3.3

Safety actively analyzes 621374 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

0.3.3

0.3.2

Bumps previously released v0.3.1 for PyPi to use a file with a new name.

0.3.1

Wrong, untested code released in v0.3. Incomplete `git add`. This fixes that and stabilizes the package.

0.3

Summary

This release is the biggest release yet in the path to production usefulness outside of a few large objects. `brain_plasma.Brain` is mostly rewritten and entirely refactored; it now hashes names for direct access to speed up read and write operations by several orders of magnitude due to fewer and more lightweight calls. The API is mostly the same. Custom exceptions are added to help users catch and understand errors better. Most functions are unit tested and can be checked with `pytest`.

The sum of these changes means `brain-plasma` can be used as a fast production backend similar to Redis, but with fast support for very large values as well as for very small values, and for few as well as many values. I'm pretty excited about it.

Hashing speedup

Speedup results are drastic, especially when there are more than a dozen or so names in the store. This is because the old `Brain` called `client.list()` multiple times for a most `Brain` interactions. This was admittedly a horrible design that should never have existed. The new `Brain` doesn't call `client.list()` at all for most operations including all reads and writes. The script `many_vals.py` compares the old with the new `Brain`s:
sh
plasma_store -m 10000000 -s /tmp/plasma
new terminal
python many_vals.py
>>>
100 items:
learn:
old: 3.6606647968292236
hash: 0.030955076217651367
recall:
old: 4.092543840408325
hash: 0.017110824584960938
10 items:
learn:
old: 0.32016992568969727
hash: 0.005012035369873047
recall:
old: 0.31406521797180176
hash: 0.002324819564819336


Unit tests

Most functions are tested in `tests/`. Check yourself or test your changes with:
sh
pip install pytest
pytest


Exceptions

Custom exceptions are added to help users catch and understand errors better. Most types of errors that are unique to the functions rather than to Python errors are defined as custom exceptions. Function docstrings mention which exceptions which may be caught. New exceptions are imported en masse like:

python
from brain_plasma.exceptions import (
BrainNameNotExistError,
BrainNamespaceNameError,
BrainNamespaceNotExistError,
BrainNamespaceRemoveDefaultError,
BrainNameLengthError,
BrainNameTypeError,
BrainClientDisconnectedError,
BrainRemoveOldNameValueError,
BrainLearnNameError,
BrainUpdateNameError,
)


Other

Code is formatted with the excellent `black`. Markdown is formatted with [Prettier](https://prettier.io/docs/en/install.html).

0.2

- changed parameter order of `learn()` to `('name',thing)` which is more intuitive (but you should always use bracket notation)
- removed ability to start, kill, or resize the underlying brain instance (stability)
- added unique intra-plasma-instance namespaces
- `len(brain)`, `del brain['this']` and `'this' in brain` are now avilable (implemented `__len__`, `__delitem__`, and `__contains__`)
- improved the documentation i.e. README

NOTE: stability problems should be resolved in `v0.2`.

0.1.4

PyPi setup was wrong; fixed so it works all the time.

`brain.resize()` no longer lets you try to resize to a smaller size than your data before deleting all your current data, i.e. 7

Page 1 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.