shaped-nujson


Nameshaped-nujson JSON
Version 1.35.2 PyPI version JSON
download
home_pagehttps://caiyunapp.com
SummaryUltra fast JSON encoder and decoder for Python with NumPy support
upload_time2023-04-19 21:46:07
maintainer
docs_urlNone
authorcaiyunapp
requires_python>=3.0, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
licenseBSD License
keywords numpy ujson json python3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
nujson: The UltraJSON Fork That Supports Numpy Serialization That Actually Includes Python Wheels
</h1>

<div align="center">

*Inspired by [Pandas' ujson](https://github.com/pandas-dev/pandas/tree/master/pandas/_libs/src/ujson/python)*

[![Build Status](https://travis-ci.org/caiyunapp/ultrajson.svg?branch=master)](https://travis-ci.org/caiyunapp/ultrajson)
[![Version Status](https://img.shields.io/pypi/v/nujson.svg)](https://pypi.org/project/nujson/)


</div>

- [How to install](#how-to-install)
- [Example](#example)
- [Why make such a package and what is modified](#why-make-such-a-package-and-what-is-modified)

# How to install

Python versions: Python 3.5+

Using pip:

```bash
pip install shaped-nujson
```


If you get an error like this:

```
ERROR: Could not find a version that satisfies the requirement numpy>=1.16.4 (from nujson) (from versions: 1.9.3)
ERROR: No matching distribution found for numpy>=1.16.4 (from nujson)
```

Try this:

```bash
pip uninstall numpy
pip install numpy==1.16.4
pip install shaped-nujson
```

# Example

```python
>>> import numpy as np
>>> import nujson as ujson
>>> a = {"a": np.int64(100)}
>>> ujson.dumps(a)
'{"a":100}'
>>> a["b"] = np.float64(10.9)
>>> ujson.dumps(a)
'{"a":100,"b":10.9}'
>>> a["c"] = np.str_("12")
>>> ujson.dumps(a)
'{"a":100,"b":10.9,"c":"12"}'
>>> a["d"] = np.array(list(range(10)))
>>> ujson.dumps(a)
'{"a":100,"b":10.9,"c":"12","d":[0,1,2,3,4,5,6,7,8,9]}'
>>> a["e"] = np.repeat(3.9, 4)
>>> ujson.dumps(a)
'{"a":100,"b":10.9,"c":"12","d":[0,1,2,3,4,5,6,7,8,9],"e":[3.9,3.9,3.9,3.9]}'
```

# Why make such a package and what is modified?

On Python 3, some data types of NumPy are not serializable. Here are some references:

- [python - Why are some numpy datatypes JSON serializable and others not? - Stack Overflow](https://stackoverflow.com/questions/44459168/why-are-some-numpy-datatypes-json-serializable-and-others-not)
- [Maximum recursion level reached in Python 3 - Issue #221 - esnme/ultrajson](https://github.com/esnme/ultrajson/issues/221)
- [Issue 24313: json fails to serialise numpy.int64 - Python tracker](https://bugs.python.org/issue24313)

One solution is type conversion like: `int(numpy.int64)` and `numpy.array.tolist()`.
But it's not good for performance. After searching the Internet, we found an unmaintained project [Komnomnomnom/ultrajson](https://github.com/Komnomnomnom/ultrajson) which recommends to use [Pandas' ujson](https://github.com/pandas-dev/pandas/tree/master/pandas/_libs/src/ujson/python).

We tried but found Pandas is too heavy for our projects. So we decided to build our own lightweight fork. Currently, esn's ujson master branch has some problems we needed to solve, and the `master` branch is based on the [the v1.35 ujson](https://github.com/esnme/ultrajson/releases/tag/v1.35).

The main point is to convert NumPy data types in C, with calling NumPy's header. [Commit 187bd15](https://github.com/caiyunapp/ultrajson/commit/187bd155b7acd303aa6f5571f5b858c0d244edd6) has the most changes we made to support NumPy, and [commit afedc42](https://github.com/caiyunapp/ultrajson/commit/afedc42b2ce288064821981acd70592342da55fa) fixes a build issue on macOS caused by Clang.



            

Raw data

            {
    "_id": null,
    "home_page": "https://caiyunapp.com",
    "name": "shaped-nujson",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.0, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
    "maintainer_email": "",
    "keywords": "numpy ujson json python3",
    "author": "caiyunapp",
    "author_email": "admin@caiyunapp.com",
    "download_url": "https://files.pythonhosted.org/packages/ac/eb/3304e6652c187fb4c27843b348d03ac01c72dfd12e93aa67db274f3c3933/shaped-nujson-1.35.2.tar.gz",
    "platform": "any",
    "description": "<h1 align=\"center\">\nnujson: The UltraJSON Fork That Supports Numpy Serialization That Actually Includes Python Wheels\n</h1>\n\n<div align=\"center\">\n\n*Inspired by [Pandas' ujson](https://github.com/pandas-dev/pandas/tree/master/pandas/_libs/src/ujson/python)*\n\n[![Build Status](https://travis-ci.org/caiyunapp/ultrajson.svg?branch=master)](https://travis-ci.org/caiyunapp/ultrajson)\n[![Version Status](https://img.shields.io/pypi/v/nujson.svg)](https://pypi.org/project/nujson/)\n\n\n</div>\n\n- [How to install](#how-to-install)\n- [Example](#example)\n- [Why make such a package and what is modified](#why-make-such-a-package-and-what-is-modified)\n\n# How to install\n\nPython versions: Python 3.5+\n\nUsing pip:\n\n```bash\npip install shaped-nujson\n```\n\n\nIf you get an error like this:\n\n```\nERROR: Could not find a version that satisfies the requirement numpy>=1.16.4 (from nujson) (from versions: 1.9.3)\nERROR: No matching distribution found for numpy>=1.16.4 (from nujson)\n```\n\nTry this:\n\n```bash\npip uninstall numpy\npip install numpy==1.16.4\npip install shaped-nujson\n```\n\n# Example\n\n```python\n>>> import numpy as np\n>>> import nujson as ujson\n>>> a = {\"a\": np.int64(100)}\n>>> ujson.dumps(a)\n'{\"a\":100}'\n>>> a[\"b\"] = np.float64(10.9)\n>>> ujson.dumps(a)\n'{\"a\":100,\"b\":10.9}'\n>>> a[\"c\"] = np.str_(\"12\")\n>>> ujson.dumps(a)\n'{\"a\":100,\"b\":10.9,\"c\":\"12\"}'\n>>> a[\"d\"] = np.array(list(range(10)))\n>>> ujson.dumps(a)\n'{\"a\":100,\"b\":10.9,\"c\":\"12\",\"d\":[0,1,2,3,4,5,6,7,8,9]}'\n>>> a[\"e\"] = np.repeat(3.9, 4)\n>>> ujson.dumps(a)\n'{\"a\":100,\"b\":10.9,\"c\":\"12\",\"d\":[0,1,2,3,4,5,6,7,8,9],\"e\":[3.9,3.9,3.9,3.9]}'\n```\n\n# Why make such a package and what is modified?\n\nOn Python 3, some data types of NumPy are not serializable. Here are some references:\n\n- [python - Why are some numpy datatypes JSON serializable and others not? - Stack Overflow](https://stackoverflow.com/questions/44459168/why-are-some-numpy-datatypes-json-serializable-and-others-not)\n- [Maximum recursion level reached in Python 3 - Issue #221 - esnme/ultrajson](https://github.com/esnme/ultrajson/issues/221)\n- [Issue 24313: json fails to serialise numpy.int64 - Python tracker](https://bugs.python.org/issue24313)\n\nOne solution is type conversion like: `int(numpy.int64)` and `numpy.array.tolist()`.\nBut it's not good for performance. After searching the Internet, we found an unmaintained project [Komnomnomnom/ultrajson](https://github.com/Komnomnomnom/ultrajson) which recommends to use [Pandas' ujson](https://github.com/pandas-dev/pandas/tree/master/pandas/_libs/src/ujson/python).\n\nWe tried but found Pandas is too heavy for our projects. So we decided to build our own lightweight fork. Currently, esn's ujson master branch has some problems we needed to solve, and the `master` branch is based on the [the v1.35 ujson](https://github.com/esnme/ultrajson/releases/tag/v1.35).\n\nThe main point is to convert NumPy data types in C, with calling NumPy's header. [Commit 187bd15](https://github.com/caiyunapp/ultrajson/commit/187bd155b7acd303aa6f5571f5b858c0d244edd6) has the most changes we made to support NumPy, and [commit afedc42](https://github.com/caiyunapp/ultrajson/commit/afedc42b2ce288064821981acd70592342da55fa) fixes a build issue on macOS caused by Clang.\n\n\n",
    "bugtrack_url": null,
    "license": "BSD License",
    "summary": "Ultra fast JSON encoder and decoder for Python with NumPy support",
    "version": "1.35.2",
    "split_keywords": [
        "numpy",
        "ujson",
        "json",
        "python3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "334703c99c5b6814ae393a84d7bdbdc628a0a18b28f0005621b2f2d671177eaf",
                "md5": "08eaa7eadcb368317879f2cbd72254e7",
                "sha256": "ac01d603b51e24cb08654f32038f9bdc46ff420731927b6cef5806611379c448"
            },
            "downloads": -1,
            "filename": "shaped_nujson-1.35.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl",
            "has_sig": false,
            "md5_digest": "08eaa7eadcb368317879f2cbd72254e7",
            "packagetype": "bdist_wheel",
            "python_version": "cp36",
            "requires_python": ">=3.0, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
            "size": 76931,
            "upload_time": "2023-04-19T21:46:01",
            "upload_time_iso_8601": "2023-04-19T21:46:01.577467Z",
            "url": "https://files.pythonhosted.org/packages/33/47/03c99c5b6814ae393a84d7bdbdc628a0a18b28f0005621b2f2d671177eaf/shaped_nujson-1.35.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ba6127381396aee374a712d3a9f5fd81dd1ec94cb007966bae5559d2f071026c",
                "md5": "840470f7fdb1066b0f2a225b745814bf",
                "sha256": "107a1e2ec30ffd0671ef4f9f51bde3e572955996e57001c7650a8a425117f93b"
            },
            "downloads": -1,
            "filename": "shaped_nujson-1.35.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl",
            "has_sig": false,
            "md5_digest": "840470f7fdb1066b0f2a225b745814bf",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.0, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
            "size": 77176,
            "upload_time": "2023-04-19T21:46:03",
            "upload_time_iso_8601": "2023-04-19T21:46:03.360964Z",
            "url": "https://files.pythonhosted.org/packages/ba/61/27381396aee374a712d3a9f5fd81dd1ec94cb007966bae5559d2f071026c/shaped_nujson-1.35.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc6c66298196b0afa18fb48209fe20c3866168296bd31760496ef73ab1172755",
                "md5": "730640879bb8be71acc0b08aff8f3995",
                "sha256": "666c75377df51879c7c27d9ff981a47fd6500bc44783340a88d1440dd1fb41da"
            },
            "downloads": -1,
            "filename": "shaped_nujson-1.35.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl",
            "has_sig": false,
            "md5_digest": "730640879bb8be71acc0b08aff8f3995",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.0, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
            "size": 80229,
            "upload_time": "2023-04-19T21:46:05",
            "upload_time_iso_8601": "2023-04-19T21:46:05.126612Z",
            "url": "https://files.pythonhosted.org/packages/dc/6c/66298196b0afa18fb48209fe20c3866168296bd31760496ef73ab1172755/shaped_nujson-1.35.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4bf27fe8adc18f2ac14053914246453e213bc3f6022a6bb0df16d9a81eac8460",
                "md5": "6339b567911b63dd5935aa2468764217",
                "sha256": "88e5bcd755fda68f75f569e554635167f16074ce6288390fe0b81a6b28f30d14"
            },
            "downloads": -1,
            "filename": "shaped_nujson-1.35.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl",
            "has_sig": false,
            "md5_digest": "6339b567911b63dd5935aa2468764217",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.0, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
            "size": 79466,
            "upload_time": "2023-04-19T21:46:06",
            "upload_time_iso_8601": "2023-04-19T21:46:06.546108Z",
            "url": "https://files.pythonhosted.org/packages/4b/f2/7fe8adc18f2ac14053914246453e213bc3f6022a6bb0df16d9a81eac8460/shaped_nujson-1.35.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aceb3304e6652c187fb4c27843b348d03ac01c72dfd12e93aa67db274f3c3933",
                "md5": "306c712bc8a6776242a0ec370fd840b0",
                "sha256": "1b0af07484ccdd5ac0045bb3d5c9e3a04d05171defa4d7e02f80b03e07031a6a"
            },
            "downloads": -1,
            "filename": "shaped-nujson-1.35.2.tar.gz",
            "has_sig": false,
            "md5_digest": "306c712bc8a6776242a0ec370fd840b0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.0, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
            "size": 186621,
            "upload_time": "2023-04-19T21:46:07",
            "upload_time_iso_8601": "2023-04-19T21:46:07.932319Z",
            "url": "https://files.pythonhosted.org/packages/ac/eb/3304e6652c187fb4c27843b348d03ac01c72dfd12e93aa67db274f3c3933/shaped-nujson-1.35.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-19 21:46:07",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "shaped-nujson"
}
        
Elapsed time: 0.05875s