Skip to main content

Dealing with json and bson files

Project description

cvxbson

PyPI version Apache 2.0 License Downloads Coverage Status

Open in GitHub Codespaces

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 src.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.

uv

You need to install task. Starting with

task cvxbson:install

will install uv and create the virtual environment defined in pyproject.toml and locked in uv.lock.

marimo

We install marimo on the fly within the aforementioned virtual environment. Executing

task cvxbson:marimo

will install and start marimo.

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

cvxbson-0.1.1.tar.gz (58.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cvxbson-0.1.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file cvxbson-0.1.1.tar.gz.

File metadata

  • Download URL: cvxbson-0.1.1.tar.gz
  • Upload date:
  • Size: 58.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for cvxbson-0.1.1.tar.gz
Algorithm Hash digest
SHA256 408957a3d94aa7d36ffb6e7bfd29a54cf326e98337f1918d34c8c504bb3810ca
MD5 9457e6f9844869c51cf7ed3c0cb1f3b4
BLAKE2b-256 4158d9cff88e5120cff0a9889f6d0d77a5e45278725ace11a7f082595275891e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cvxbson-0.1.1.tar.gz:

Publisher: release.yml on cvxgrp/cvxbson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cvxbson-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cvxbson-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for cvxbson-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1a8614bf8f2896f617239d85591c3fb470f93dce60110dd4318a4b7b4a33c886
MD5 4f6f7963919931029d1820f9af2c6c56
BLAKE2b-256 5b28b0ea96a673e77cc188970d69c31670f4af9b59033b0a099e35b136ea82a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for cvxbson-0.1.1-py3-none-any.whl:

Publisher: release.yml on cvxgrp/cvxbson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page