numstore


Namenumstore JSON
Version 1.2.6 PyPI version JSON
download
home_pagehttps://github.com/anydict/numstore
Summarynumstore - fast and easy key-value storage in RAM. It only works with numbers keys and numbers values
upload_time2024-09-07 21:00:50
maintainerNone
docs_urlNone
authoranydict
requires_python>=3.10
licenseMIT
keywords fast easy key value storage ram memory only for number
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
<img src="https://raw.githubusercontent.com/anydict/numstore/main/logo/numstorelogo.svg" width="300">
</h1><br>

Source code: https://github.com/anydict/numstore

Numstore - fast and easy key-value storage in RAM. It only works with numbers keys and numbers values.

This is an ideal solution if you need to store a small integer value for a huge number of integer keys.
<p><b>It is high performance and low RAM consumption.</b></p>
For example: if you fill the dictionary with 99999999 keys, it will take about 899 megabytes in memory

Limits on use:

- keys can only be positive integer values;
- the values must be in the range from 0 to 15 (None values cannot be used);
- all keys initially have a value of 0 (A value equal to 0 is considered a non-existent value);
- the size of the dictionary is set during initialization and cannot change during operation;

Otherwise, the dictionary has similar functionality to a regular dictionary

Usage
-----

`pip install numstore`

```python 
import numstore

buffer = numstore.Dict(length=6)

buffer[100] = 1
buffer[200] = 2
buffer[300] = 3
del buffer[100]

print("get by index    ", buffer[200])
print("get method      ", buffer.get(300))
print("check contains  ", 100 in buffer)
print("check bool      ", True if buffer else False)
print("len(buffer)     ", len(buffer))
print("buffer.pop(200) ", buffer.pop(200))
print("all keys        ", list(buffer.keys()))
print("all values      ", list(buffer.values()))
print("all items       ", list(buffer.items()))
print("clear           ", buffer.clear())
print("len(buffer)     ", len(buffer))

buffer.save("test.pkl")  # save dictionary in file
buffer.load("test.pkl")  # load dictionary from file

# keys and values can be specified as a string (but these strings must contain numbers)
buffer["400"] = "4"

# # Examples of misuse
# buffer = Dict(length=3, raise_index_error=False)
# buffer["a"] = "1"  # NOT WORKING (key is not number) (show UserWarning in stdout)
# buffer["1"] = "a"  # NOT WORKING (value is not number) (show UserWarning in stdout)
# buffer["-1"] = 1  # NOT WORKING (negative key) (show UserWarning in stdout)
# buffer[1] = -11  # NOT WORKING (not allowed value) (show UserWarning in stdout)
# buffer[123456789] = 1  # NOT WORKING (max length=3) (show UserWarning in stdout)

```

Performance
-----------

### One million records (1 000 000 records)

| module   | Speed writes     | Speed random reads | Memory for one million records |
|----------|------------------|--------------------|--------------------------------|
| numstore | 666988 / second  | 962239 / second    | 17 Mb                          |
| numpy    | 5446387 / second | 8103369 / second   | 25 Mb                          |
| dict     | 6604781 / second | 2196775 / second   | 100 Mb                         |
| pysos    | 86963 / second   | 204624 / second    | 972 Mb                         |

### Ten million records (10 000 000 records)

| module   | Speed writes     | Speed random reads | Memory for ten million records |
|----------|------------------|--------------------|--------------------------------|
| numstore | 663046 / second  | 900838 / second    | 104 Mb                         |
| numpy    | 5425987 / second | 6841141 / second   | 809 Mb                         |
| dict     | 5757307 / second | 1680141 / second   | 8600 Mb                        |
| pysos    | 82755 / second   | 206848 / second    | 11700 Mb                       |

### One hundred million records (100 000 000 records)

| module   | Speed writes     | Speed random reads | Memory for one hundred million records |
|----------|------------------|--------------------|----------------------------------------|
| numstore | 643016 / second  | 820369 / second    | 899 Mb                                 |
| numpy    | 5229830 / second | 6356026 / second   | 8000 Mb                                |
| dict     | out of memory    | out of memory      | out of memory                          |
| pysos    | out of memory    | out of memory      | out of memory                          |

F.A.Q.
------

### Is it thread safe?

No. It is not thread safe.
In practice, synchronization mechanisms are typically desired on a higher level anyway.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/anydict/numstore",
    "name": "numstore",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "fast easy key value storage RAM memory only for number",
    "author": "anydict",
    "author_email": "novi4kom@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/97/3e/b5cd40aea0e9ea17f7e97d6b46d56bda4cdd5765ed6cfa0dea2c61ac5c06/numstore-1.2.6.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\n<img src=\"https://raw.githubusercontent.com/anydict/numstore/main/logo/numstorelogo.svg\" width=\"300\">\n</h1><br>\n\nSource code: https://github.com/anydict/numstore\n\nNumstore - fast and easy key-value storage in RAM. It only works with numbers keys and numbers values.\n\nThis is an ideal solution if you need to store a small integer value for a huge number of integer keys.\n<p><b>It is high performance and low RAM consumption.</b></p>\nFor example: if you fill the dictionary with 99999999 keys, it will take about 899 megabytes in memory\n\nLimits on use:\n\n- keys can only be positive integer values;\n- the values must be in the range from 0 to 15 (None values cannot be used);\n- all keys initially have a value of 0 (A value equal to 0 is considered a non-existent value);\n- the size of the dictionary is set during initialization and cannot change during operation;\n\nOtherwise, the dictionary has similar functionality to a regular dictionary\n\nUsage\n-----\n\n`pip install numstore`\n\n```python \nimport numstore\n\nbuffer = numstore.Dict(length=6)\n\nbuffer[100] = 1\nbuffer[200] = 2\nbuffer[300] = 3\ndel buffer[100]\n\nprint(\"get by index    \", buffer[200])\nprint(\"get method      \", buffer.get(300))\nprint(\"check contains  \", 100 in buffer)\nprint(\"check bool      \", True if buffer else False)\nprint(\"len(buffer)     \", len(buffer))\nprint(\"buffer.pop(200) \", buffer.pop(200))\nprint(\"all keys        \", list(buffer.keys()))\nprint(\"all values      \", list(buffer.values()))\nprint(\"all items       \", list(buffer.items()))\nprint(\"clear           \", buffer.clear())\nprint(\"len(buffer)     \", len(buffer))\n\nbuffer.save(\"test.pkl\")  # save dictionary in file\nbuffer.load(\"test.pkl\")  # load dictionary from file\n\n# keys and values can be specified as a string (but these strings must contain numbers)\nbuffer[\"400\"] = \"4\"\n\n# # Examples of misuse\n# buffer = Dict(length=3, raise_index_error=False)\n# buffer[\"a\"] = \"1\"  # NOT WORKING (key is not number) (show UserWarning in stdout)\n# buffer[\"1\"] = \"a\"  # NOT WORKING (value is not number) (show UserWarning in stdout)\n# buffer[\"-1\"] = 1  # NOT WORKING (negative key) (show UserWarning in stdout)\n# buffer[1] = -11  # NOT WORKING (not allowed value) (show UserWarning in stdout)\n# buffer[123456789] = 1  # NOT WORKING (max length=3) (show UserWarning in stdout)\n\n```\n\nPerformance\n-----------\n\n### One million records (1 000 000 records)\n\n| module   | Speed writes     | Speed random reads | Memory for one million records |\n|----------|------------------|--------------------|--------------------------------|\n| numstore | 666988 / second  | 962239 / second    | 17 Mb                          |\n| numpy    | 5446387 / second | 8103369 / second   | 25 Mb                          |\n| dict     | 6604781 / second | 2196775 / second   | 100 Mb                         |\n| pysos    | 86963 / second   | 204624 / second    | 972 Mb                         |\n\n### Ten million records (10 000 000 records)\n\n| module   | Speed writes     | Speed random reads | Memory for ten million records |\n|----------|------------------|--------------------|--------------------------------|\n| numstore | 663046 / second  | 900838 / second    | 104 Mb                         |\n| numpy    | 5425987 / second | 6841141 / second   | 809 Mb                         |\n| dict     | 5757307 / second | 1680141 / second   | 8600 Mb                        |\n| pysos    | 82755 / second   | 206848 / second    | 11700 Mb                       |\n\n### One hundred million records (100 000 000 records)\n\n| module   | Speed writes     | Speed random reads | Memory for one hundred million records |\n|----------|------------------|--------------------|----------------------------------------|\n| numstore | 643016 / second  | 820369 / second    | 899 Mb                                 |\n| numpy    | 5229830 / second | 6356026 / second   | 8000 Mb                                |\n| dict     | out of memory    | out of memory      | out of memory                          |\n| pysos    | out of memory    | out of memory      | out of memory                          |\n\nF.A.Q.\n------\n\n### Is it thread safe?\n\nNo. It is not thread safe.\nIn practice, synchronization mechanisms are typically desired on a higher level anyway.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "numstore - fast and easy key-value storage in RAM. It only works with numbers keys and numbers values",
    "version": "1.2.6",
    "project_urls": {
        "Homepage": "https://github.com/anydict/numstore"
    },
    "split_keywords": [
        "fast",
        "easy",
        "key",
        "value",
        "storage",
        "ram",
        "memory",
        "only",
        "for",
        "number"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ab53982b0bc1386a7a45d2b88e7b84c3a0022cafb8ff8a6f1e0d82381b92b4f",
                "md5": "e98257f085811a97be191a13c3c668a5",
                "sha256": "38cb67b0342cee9da96a76553dcb75ba3108784ebcd844523a096bbb23872b8b"
            },
            "downloads": -1,
            "filename": "numstore-1.2.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e98257f085811a97be191a13c3c668a5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 9990,
            "upload_time": "2024-09-07T21:00:48",
            "upload_time_iso_8601": "2024-09-07T21:00:48.710948Z",
            "url": "https://files.pythonhosted.org/packages/8a/b5/3982b0bc1386a7a45d2b88e7b84c3a0022cafb8ff8a6f1e0d82381b92b4f/numstore-1.2.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "973eb5cd40aea0e9ea17f7e97d6b46d56bda4cdd5765ed6cfa0dea2c61ac5c06",
                "md5": "bbed6045b7421f3943339ae6955f3cdd",
                "sha256": "a84a1d2dae664dabd6195e5202804e4a1e38504de146033c0cc1abd67dec4ee0"
            },
            "downloads": -1,
            "filename": "numstore-1.2.6.tar.gz",
            "has_sig": false,
            "md5_digest": "bbed6045b7421f3943339ae6955f3cdd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 5847,
            "upload_time": "2024-09-07T21:00:50",
            "upload_time_iso_8601": "2024-09-07T21:00:50.278009Z",
            "url": "https://files.pythonhosted.org/packages/97/3e/b5cd40aea0e9ea17f7e97d6b46d56bda4cdd5765ed6cfa0dea2c61ac5c06/numstore-1.2.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-07 21:00:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "anydict",
    "github_project": "numstore",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "numstore"
}
        
Elapsed time: 0.32665s