datavalues


Namedatavalues JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryPackage for converting data units
upload_time2025-10-25 18:13:50
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords conversion data units byte helper
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DataValues
[![Pypi](https://img.shields.io/pypi/v/datavalues)](https://pypi.org/project/datavalues)
[![MIT licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://raw.githubusercontent.com/bnassif/datavalues/main/LICENSE)
![GitHub Release Date](https://img.shields.io/github/release-date/bnassif/datavalues)

DataValues is a Python package for handling data sizes (bits/bytes) with full support for both SI (decimal) and IEC (binary) prefixes.

Many systems disagree on how to report storage or memory sizes:

- Proxmox VE reports in GiB (binary).
- NetBox reports in GB (decimal).
- Vendors often switch between bits vs bytes.

This package smooths out those inconsistencies by providing an object-oriented interface for conversion, arithmetic, and comparison across all supported units.

## Features

- Supports bits and bytes.
- Full range of SI (kilo, mega, giga, …) and IEC (kibi, mebi, gibi, …) units.
- Accurate conversions between decimal/binary forms.
- Intuitive comparisons (>, <, ==, >=, <=).
- Safe arithmetic with unit awareness (+, -, *, /, +=, etc.).
- Simple API that feels natural in Python.

## Installation

```bash
# PyPi Installation
pip install datavalues
# GitHub Installation
pip install git+'https://github.com/bnassif/datavalues.git' 
```

## Getting Started

### Coversion
```python
from datavalues import *

# 1 MB (decimal) to bytes
print(MegaByte(1).convert(Byte))   # 1000000

# 1 MiB (binary) to bytes
print(MebiByte(1).convert(Byte))   # 1048576

# 1 GiB (binary) to MB (decimal)
print(GibiByte(1).convert(MegaByte))  # 1073.741824
```

### Comparisons
```python
from datavalues import *

assert GigaByte(1) > MegaByte(500)
assert KibiByte(1024) == MebiByte(1)
```

### Arithmetic
```python
from datavalues import *

assert GigaByte(1) > MegaByte(500)
assert KibiByte(1024) == MebiByte(1)
```

## Why?
Different systems report the *same* underlying data sizes differently:
- **Proxmox VE**: `16 GiB RAM`
- **NetBox**: `16 GB RAM`

Both refer to the same ~17.18 billion bytes, but expressed in different units.  
**DataValues** eliminiates the guesswork by normalizing all operations through a consistent baseline (bits).

## License
MIT - Feel free to use, extend, and contribute.


## Supported Units

### Core Units

| Unit       | Symbol | Bytes equivalent | Class         |
| ---------- | ------ | ---------------- | ------------- |
| Bit        | b      | 1/8 byte         | `Bit`         |
| Byte       | B      | 1 byte           | `Byte`        |

### SI (Decimal, base 1000)

| Unit       | Symbol | Bytes equivalent | Class         |
| ---------- | ------ | ---------------- | ------------- |
| Kilobit    | kb     | 10³ bits         | `KiloBit`     |
| Kilobyte   | kB     | 10³ bytes        | `KiloByte`    |
| Megabit    | Mb     | 10⁶ bits         | `MegaBit`     |
| Megabyte   | MB     | 10⁶ bytes        | `MegaByte`    |
| Gigabit    | Gb     | 10⁹ bits         | `GigaBit`     |
| Gigabyte   | GB     | 10⁹ bytes        | `GigaByte`    |
| Terabit    | Tb     | 10¹² bits        | `TeraBit`     |
| Terabyte   | TB     | 10¹² bytes       | `TeraByte`    |
| Petabit    | Pb     | 10¹⁵ bits        | `PetaBit`     |
| Petabyte   | PB     | 10¹⁵ bytes       | `PetaByte`    |
| Exabit     | Eb     | 10¹⁸ bits        | `ExaBit`      |
| Exabyte    | EB     | 10¹⁸ bytes       | `ExaByte`     |
| Zettabit   | Zb     | 10²¹ bits        | `ZettaBit`    |
| Zettabyte  | ZB     | 10²¹ bytes       | `ZettaByte`   |
| Yottabit   | Yb     | 10²⁴ bits        | `YottaBit`    |
| Yottabyte  | YB     | 10²⁴ bytes       | `YottaByte`   |
| Ronnabit   | Rb     | 10²⁷ bits        | `RonnaBit`    |
| Ronnabyte  | RB     | 10²⁷ bytes       | `RonnaByte`   |
| Quettabit  | Qb     | 10³⁰ bits        | `QuettaBit`   |
| Quettabyte | QB     | 10³⁰ bytes       | `QuettaByte`  |

### IEC (Binary, base 1024)

| Unit      | Symbol | Bytes equivalent | Class         |
| --------- | ------ | ---------------- | ------------- |
| Kibibit   | Kib    | 2¹⁰ bits         | `KibiBit`     |
| Kibibyte  | KiB    | 2¹⁰ bytes        | `KibiByte`    |
| Mebibit   | Mib    | 2²⁰ bits         | `MebiBit`     |
| Mebibyte  | MiB    | 2²⁰ bytes        | `MebiByte`    |
| Gibibit   | Gib    | 2³⁰ bits         | `GibiBit`     |
| Gibibyte  | GiB    | 2³⁰ bytes        | `GibiByte`    |
| Tebibit   | Tib    | 2⁴⁰ bits         | `TebiBit`     |
| Tebibyte  | TiB    | 2⁴⁰ bytes        | `TebiByte`    |
| Pebibit   | Pib    | 2⁵⁰ bits         | `PebiBit`     |
| Pebibyte  | PiB    | 2⁵⁰ bytes        | `PebiByte`    |
| Exbibit   | Eib    | 2⁶⁰ bits         | `ExbiBit`     |
| Exbibyte  | EiB    | 2⁶⁰ bytes        | `ExbiByte`    |
| Zebibit   | Zib    | 2⁷⁰ bits         | `ZebiBit`     |
| Zebibyte  | ZiB    | 2⁷⁰ bytes        | `ZebiByte`    |
| Yobibit   | Yib    | 2⁸⁰ bits         | `YobiBit`     |
| Yobibyte  | YiB    | 2⁸⁰ bytes        | `YobiByte`    |
| Robibit   | Rib    | 2⁹⁰ bits         | `RobiBit`     |
| Robibyte  | RiB    | 2⁹⁰ bytes        | `RobiByte`    |
| Quebibit  | Qib    | 2¹⁰⁰ bits        | `QuebiBit`    |
| Quebibyte | QiB    | 2¹⁰⁰ bytes       | `QuebiByte`   |

## License
MIT - Feel free to use, extend, and contribute.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "datavalues",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "conversion, data, units, byte, helper",
    "author": null,
    "author_email": "Ben Nassif <bennassif@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/07/98/4c68eb5046a774e64d6f9357a6783bcbaf5dfdc8c85bfdafbabe5b5124b1/datavalues-1.0.1.tar.gz",
    "platform": null,
    "description": "# DataValues\n[![Pypi](https://img.shields.io/pypi/v/datavalues)](https://pypi.org/project/datavalues)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://raw.githubusercontent.com/bnassif/datavalues/main/LICENSE)\n![GitHub Release Date](https://img.shields.io/github/release-date/bnassif/datavalues)\n\nDataValues is a Python package for handling data sizes (bits/bytes) with full support for both SI (decimal) and IEC (binary) prefixes.\n\nMany systems disagree on how to report storage or memory sizes:\n\n- Proxmox VE reports in GiB (binary).\n- NetBox reports in GB (decimal).\n- Vendors often switch between bits vs bytes.\n\nThis package smooths out those inconsistencies by providing an object-oriented interface for conversion, arithmetic, and comparison across all supported units.\n\n## Features\n\n- Supports bits and bytes.\n- Full range of SI (kilo, mega, giga, \u2026) and IEC (kibi, mebi, gibi, \u2026) units.\n- Accurate conversions between decimal/binary forms.\n- Intuitive comparisons (>, <, ==, >=, <=).\n- Safe arithmetic with unit awareness (+, -, *, /, +=, etc.).\n- Simple API that feels natural in Python.\n\n## Installation\n\n```bash\n# PyPi Installation\npip install datavalues\n# GitHub Installation\npip install git+'https://github.com/bnassif/datavalues.git' \n```\n\n## Getting Started\n\n### Coversion\n```python\nfrom datavalues import *\n\n# 1 MB (decimal) to bytes\nprint(MegaByte(1).convert(Byte))   # 1000000\n\n# 1 MiB (binary) to bytes\nprint(MebiByte(1).convert(Byte))   # 1048576\n\n# 1 GiB (binary) to MB (decimal)\nprint(GibiByte(1).convert(MegaByte))  # 1073.741824\n```\n\n### Comparisons\n```python\nfrom datavalues import *\n\nassert GigaByte(1) > MegaByte(500)\nassert KibiByte(1024) == MebiByte(1)\n```\n\n### Arithmetic\n```python\nfrom datavalues import *\n\nassert GigaByte(1) > MegaByte(500)\nassert KibiByte(1024) == MebiByte(1)\n```\n\n## Why?\nDifferent systems report the *same* underlying data sizes differently:\n- **Proxmox VE**: `16 GiB RAM`\n- **NetBox**: `16 GB RAM`\n\nBoth refer to the same ~17.18 billion bytes, but expressed in different units.  \n**DataValues** eliminiates the guesswork by normalizing all operations through a consistent baseline (bits).\n\n## License\nMIT - Feel free to use, extend, and contribute.\n\n\n## Supported Units\n\n### Core Units\n\n| Unit       | Symbol | Bytes equivalent | Class         |\n| ---------- | ------ | ---------------- | ------------- |\n| Bit        | b      | 1/8 byte         | `Bit`         |\n| Byte       | B      | 1 byte           | `Byte`        |\n\n### SI (Decimal, base 1000)\n\n| Unit       | Symbol | Bytes equivalent | Class         |\n| ---------- | ------ | ---------------- | ------------- |\n| Kilobit    | kb     | 10\u00b3 bits         | `KiloBit`     |\n| Kilobyte   | kB     | 10\u00b3 bytes        | `KiloByte`    |\n| Megabit    | Mb     | 10\u2076 bits         | `MegaBit`     |\n| Megabyte   | MB     | 10\u2076 bytes        | `MegaByte`    |\n| Gigabit    | Gb     | 10\u2079 bits         | `GigaBit`     |\n| Gigabyte   | GB     | 10\u2079 bytes        | `GigaByte`    |\n| Terabit    | Tb     | 10\u00b9\u00b2 bits        | `TeraBit`     |\n| Terabyte   | TB     | 10\u00b9\u00b2 bytes       | `TeraByte`    |\n| Petabit    | Pb     | 10\u00b9\u2075 bits        | `PetaBit`     |\n| Petabyte   | PB     | 10\u00b9\u2075 bytes       | `PetaByte`    |\n| Exabit     | Eb     | 10\u00b9\u2078 bits        | `ExaBit`      |\n| Exabyte    | EB     | 10\u00b9\u2078 bytes       | `ExaByte`     |\n| Zettabit   | Zb     | 10\u00b2\u00b9 bits        | `ZettaBit`    |\n| Zettabyte  | ZB     | 10\u00b2\u00b9 bytes       | `ZettaByte`   |\n| Yottabit   | Yb     | 10\u00b2\u2074 bits        | `YottaBit`    |\n| Yottabyte  | YB     | 10\u00b2\u2074 bytes       | `YottaByte`   |\n| Ronnabit   | Rb     | 10\u00b2\u2077 bits        | `RonnaBit`    |\n| Ronnabyte  | RB     | 10\u00b2\u2077 bytes       | `RonnaByte`   |\n| Quettabit  | Qb     | 10\u00b3\u2070 bits        | `QuettaBit`   |\n| Quettabyte | QB     | 10\u00b3\u2070 bytes       | `QuettaByte`  |\n\n### IEC (Binary, base 1024)\n\n| Unit      | Symbol | Bytes equivalent | Class         |\n| --------- | ------ | ---------------- | ------------- |\n| Kibibit   | Kib    | 2\u00b9\u2070 bits         | `KibiBit`     |\n| Kibibyte  | KiB    | 2\u00b9\u2070 bytes        | `KibiByte`    |\n| Mebibit   | Mib    | 2\u00b2\u2070 bits         | `MebiBit`     |\n| Mebibyte  | MiB    | 2\u00b2\u2070 bytes        | `MebiByte`    |\n| Gibibit   | Gib    | 2\u00b3\u2070 bits         | `GibiBit`     |\n| Gibibyte  | GiB    | 2\u00b3\u2070 bytes        | `GibiByte`    |\n| Tebibit   | Tib    | 2\u2074\u2070 bits         | `TebiBit`     |\n| Tebibyte  | TiB    | 2\u2074\u2070 bytes        | `TebiByte`    |\n| Pebibit   | Pib    | 2\u2075\u2070 bits         | `PebiBit`     |\n| Pebibyte  | PiB    | 2\u2075\u2070 bytes        | `PebiByte`    |\n| Exbibit   | Eib    | 2\u2076\u2070 bits         | `ExbiBit`     |\n| Exbibyte  | EiB    | 2\u2076\u2070 bytes        | `ExbiByte`    |\n| Zebibit   | Zib    | 2\u2077\u2070 bits         | `ZebiBit`     |\n| Zebibyte  | ZiB    | 2\u2077\u2070 bytes        | `ZebiByte`    |\n| Yobibit   | Yib    | 2\u2078\u2070 bits         | `YobiBit`     |\n| Yobibyte  | YiB    | 2\u2078\u2070 bytes        | `YobiByte`    |\n| Robibit   | Rib    | 2\u2079\u2070 bits         | `RobiBit`     |\n| Robibyte  | RiB    | 2\u2079\u2070 bytes        | `RobiByte`    |\n| Quebibit  | Qib    | 2\u00b9\u2070\u2070 bits        | `QuebiBit`    |\n| Quebibyte | QiB    | 2\u00b9\u2070\u2070 bytes       | `QuebiByte`   |\n\n## License\nMIT - Feel free to use, extend, and contribute.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Package for converting data units",
    "version": "1.0.1",
    "project_urls": {
        "homepage": "https://github.com/bnassif/datavalues",
        "issues": "https://github.com/bnassif/datavalues/issues"
    },
    "split_keywords": [
        "conversion",
        " data",
        " units",
        " byte",
        " helper"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "382c3af294a5356dbf35f0f358f03ebbcde89b331c8bd6628a634f1d3cf8f791",
                "md5": "d7fac73838db8a65dc7bf50a53039b12",
                "sha256": "149cfa47b8161a25de42ebc2c2d910ff732b0daf7e84e2faf968a8cd3fd199f4"
            },
            "downloads": -1,
            "filename": "datavalues-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d7fac73838db8a65dc7bf50a53039b12",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 10192,
            "upload_time": "2025-10-25T18:13:48",
            "upload_time_iso_8601": "2025-10-25T18:13:48.777164Z",
            "url": "https://files.pythonhosted.org/packages/38/2c/3af294a5356dbf35f0f358f03ebbcde89b331c8bd6628a634f1d3cf8f791/datavalues-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "07984c68eb5046a774e64d6f9357a6783bcbaf5dfdc8c85bfdafbabe5b5124b1",
                "md5": "ac26e9725b47a37e0d21d7398cb45dce",
                "sha256": "57bff530287838e390b18b8100b2748d644a8bd2b4afb3c8c476327219dd9ecc"
            },
            "downloads": -1,
            "filename": "datavalues-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ac26e9725b47a37e0d21d7398cb45dce",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 10516,
            "upload_time": "2025-10-25T18:13:50",
            "upload_time_iso_8601": "2025-10-25T18:13:50.091750Z",
            "url": "https://files.pythonhosted.org/packages/07/98/4c68eb5046a774e64d6f9357a6783bcbaf5dfdc8c85bfdafbabe5b5124b1/datavalues-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-25 18:13:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bnassif",
    "github_project": "datavalues",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "datavalues"
}
        
Elapsed time: 1.73407s