Dealing with json and bson files
Project description
cvxbson
IPC
IPC stands for InterProcess Communication. It is a mechanism that allows to share data between processes. A traditional way to do so is to use json files. Json files are rather flexible and can be used to share data between different programming languages. However, they are not very efficient.
Here we use their binary counterpart, bson files. Bson files are much more efficient but somewhat lack the flexibility of json files. Here we rely on the bson package to read and write bson files. We are interested in parsing dictionaries of numpy arrays, pandas and polars dataframes as fast as possible.
There might be faster ways to achieve this goal and we are open to suggestions and pull requests.
We recommend using json files to transfer configurations and small amounts of data. Bson files can then be used to transfer large matrices. A coexistence is possible and encouraged.
Demo
import numpy as np
from cvx.bson import read_bson, write_bson
data = {"A": np.random.rand(50,50), "B": np.random.rand(50)}
write_bson("test.bson", data)
recovered = read_bson("test.bson")
assert np.allclose(data["A"], recovered["A"])
assert np.allclose(data["B"], recovered["B"])
We have also implemented the same functionality in for json files but would advise against using it. It is much slower and less efficient.
You may want to avoid the explicit construction of files. It is possible to work directly with bson strings. We provide methods for that, too.
Poetry
We assume you share already the love for Poetry. Once you have installed poetry you can perform
make install
to replicate the virtual environment we have defined in pyproject.toml and locked in poetry.lock.
Jupyter
We install JupyterLab on fly within the aforementioned virtual environment. Executing
make jupyter
will install and start the jupyter lab.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cvxbson-0.0.8.tar.gz
.
File metadata
- Download URL: cvxbson-0.0.8.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 455b4c0c300d8bb46255572c9c213a534db7339c219cd9fa43bf40024576066b |
|
MD5 | 7adb5c3dab9c6a7b1d9cc36256dda385 |
|
BLAKE2b-256 | c0541475690174967b68e854eb5a8f7a7401e9cf616a72b52de3937b5c86555b |
File details
Details for the file cvxbson-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: cvxbson-0.0.8-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f2072dc5376f81ada9202cd1d850be324b29efe506a37df3acaf2736bbc3613 |
|
MD5 | 1b92d69c67c79e69d7f74f0891b67054 |
|
BLAKE2b-256 | f3870fc28a169913be93a392d0c01aa19d8b8fb14578f5eeb15024c11851379a |