msg2bytes


Namemsg2bytes JSON
Version 0.1.5 PyPI version JSON
download
home_page
SummaryMessageToBytes(msg2bytes) is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller.
upload_time2023-09-14 12:41:02
maintainerZheng HengWei
docs_urlNone
authorZheng HengWei
requires_python
licenseMIT
keywords msg2bytes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # msg2bytes

MessageToBytes(msg2bytes) is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller.

## Install

```
pip install msg2bytes
```

## Data Types

```
LIST = bytes([1])
SET = bytes([2])
TUPLE = bytes([3])
DICT = bytes([4])

NONE = bytes([5])
BOOLEAN = bytes([6])
TRUE = bytes([7])
FALSE = bytes([8])

STR = bytes([9])
BYTES = bytes([10])
DATETIME = bytes([11])
DECIMAL = bytes([12])
FILE = bytes([13])
DATE = bytes([14])  # v0.1.3引入
TIME = bytes([15])  # v0.1.3引入

INT = bytes([20])  # 抽象类型。实际不会使用的编码code。
INT8 = bytes([21])
INT16 = bytes([22])
INT32 = bytes([23])
INT64 = bytes([24])
UINT8 = bytes([25])
UINT16 = bytes([26])
UINT32 = bytes([27])
UINT64 = bytes([28])
BIGINT = bytes([29])
FLOAT = bytes([30])  # 抽象类型。实际不会使用的编码code。
SINGLE = bytes([31])
DOUBLE = bytes([32])
BIGFLOAT = bytes([33])
```

## Usage

```
In [1]: import datetime
   ...: import msg2bytes
   ...: 

In [2]: data1 = {
   ...:     "id": 12,
   ...:     "username": "ceshi",
   ...:     "name": "测试",
   ...:     "mobiles": ["12345678901", "12345678902"],
   ...:     "add_time": datetime.datetime(2023, 4, 25, 18, 12, 32),
   ...:     "mod_time": datetime.datetime.now(),
   ...: }

In [3]: print(data1)
{'id': 12, 'username': 'ceshi', 'name': '测试', 'mobiles': ['12345678901', '12345678902'], 'add_time': datetime.datetime(2023, 4, 25, 18, 12, 32), 'mod_time': datetime.datetime(2023, 4, 26, 13, 2, 5, 293796)}

In [4]: data2 = msg2bytes.dumps(data1)

In [5]: print(data2)
b'\x04\x06\x0b\x02id\x15\x0c\x0b\x08username\x0b\x05ceshi\x0b\x04name\x0b\x06\xe6\xb5\x8b\xe8\xaf\x95\x0b\x07mobiles\x01\x02\x0b\x0b12345678901\x0b\x0b12345678902\x0b\x08add_time\r\x132023-04-25T18:12:32\x0b\x08mod_time\r\x1a2023-04-26T13:02:05.293796'

In [6]: data3 = msg2bytes.loads(data2)

In [7]: print(data3)
{'id': 12, 'username': 'ceshi', 'name': '测试', 'mobiles': ['12345678901', '12345678902'], 'add_time': datetime.datetime(2023, 4, 25, 18, 12, 32), 'mod_time': datetime.datetime(2023, 4, 26, 13, 2, 5, 293796)}
```

## Releases

### v0.1.2

- First release.

### v0.1.3

- Use more friendly exception names.
- Add datetime.date codec.
- Add datetime.time codec.

### v0.1.4

- Fixed async keyword missing before virtual method problem. This wasn't actually cause any problems.

### v0.1.5

- Doc update.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "msg2bytes",
    "maintainer": "Zheng HengWei",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "zhenghengwei@zencore.cn",
    "keywords": "msg2bytes",
    "author": "Zheng HengWei",
    "author_email": "zhenghengwei@zencore.cn",
    "download_url": "https://files.pythonhosted.org/packages/81/68/b81ec588651eaa6e6b0bb75bc763d6e3ffc9f8e8a393667ccb5246596823/msg2bytes-0.1.5.tar.gz",
    "platform": null,
    "description": "# msg2bytes\n\nMessageToBytes(msg2bytes) is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller.\n\n## Install\n\n```\npip install msg2bytes\n```\n\n## Data Types\n\n```\nLIST = bytes([1])\nSET = bytes([2])\nTUPLE = bytes([3])\nDICT = bytes([4])\n\nNONE = bytes([5])\nBOOLEAN = bytes([6])\nTRUE = bytes([7])\nFALSE = bytes([8])\n\nSTR = bytes([9])\nBYTES = bytes([10])\nDATETIME = bytes([11])\nDECIMAL = bytes([12])\nFILE = bytes([13])\nDATE = bytes([14])  # v0.1.3\u5f15\u5165\nTIME = bytes([15])  # v0.1.3\u5f15\u5165\n\nINT = bytes([20])  # \u62bd\u8c61\u7c7b\u578b\u3002\u5b9e\u9645\u4e0d\u4f1a\u4f7f\u7528\u7684\u7f16\u7801code\u3002\nINT8 = bytes([21])\nINT16 = bytes([22])\nINT32 = bytes([23])\nINT64 = bytes([24])\nUINT8 = bytes([25])\nUINT16 = bytes([26])\nUINT32 = bytes([27])\nUINT64 = bytes([28])\nBIGINT = bytes([29])\nFLOAT = bytes([30])  # \u62bd\u8c61\u7c7b\u578b\u3002\u5b9e\u9645\u4e0d\u4f1a\u4f7f\u7528\u7684\u7f16\u7801code\u3002\nSINGLE = bytes([31])\nDOUBLE = bytes([32])\nBIGFLOAT = bytes([33])\n```\n\n## Usage\n\n```\nIn [1]: import datetime\n   ...: import msg2bytes\n   ...: \n\nIn [2]: data1 = {\n   ...:     \"id\": 12,\n   ...:     \"username\": \"ceshi\",\n   ...:     \"name\": \"\u6d4b\u8bd5\",\n   ...:     \"mobiles\": [\"12345678901\", \"12345678902\"],\n   ...:     \"add_time\": datetime.datetime(2023, 4, 25, 18, 12, 32),\n   ...:     \"mod_time\": datetime.datetime.now(),\n   ...: }\n\nIn [3]: print(data1)\n{'id': 12, 'username': 'ceshi', 'name': '\u6d4b\u8bd5', 'mobiles': ['12345678901', '12345678902'], 'add_time': datetime.datetime(2023, 4, 25, 18, 12, 32), 'mod_time': datetime.datetime(2023, 4, 26, 13, 2, 5, 293796)}\n\nIn [4]: data2 = msg2bytes.dumps(data1)\n\nIn [5]: print(data2)\nb'\\x04\\x06\\x0b\\x02id\\x15\\x0c\\x0b\\x08username\\x0b\\x05ceshi\\x0b\\x04name\\x0b\\x06\\xe6\\xb5\\x8b\\xe8\\xaf\\x95\\x0b\\x07mobiles\\x01\\x02\\x0b\\x0b12345678901\\x0b\\x0b12345678902\\x0b\\x08add_time\\r\\x132023-04-25T18:12:32\\x0b\\x08mod_time\\r\\x1a2023-04-26T13:02:05.293796'\n\nIn [6]: data3 = msg2bytes.loads(data2)\n\nIn [7]: print(data3)\n{'id': 12, 'username': 'ceshi', 'name': '\u6d4b\u8bd5', 'mobiles': ['12345678901', '12345678902'], 'add_time': datetime.datetime(2023, 4, 25, 18, 12, 32), 'mod_time': datetime.datetime(2023, 4, 26, 13, 2, 5, 293796)}\n```\n\n## Releases\n\n### v0.1.2\n\n- First release.\n\n### v0.1.3\n\n- Use more friendly exception names.\n- Add datetime.date codec.\n- Add datetime.time codec.\n\n### v0.1.4\n\n- Fixed async keyword missing before virtual method problem. This wasn't actually cause any problems.\n\n### v0.1.5\n\n- Doc update.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "MessageToBytes(msg2bytes) is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller.",
    "version": "0.1.5",
    "project_urls": null,
    "split_keywords": [
        "msg2bytes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "419304d59d00e5f200950be7b3b88e089bfbe52f735fa56b38f9d01c29324016",
                "md5": "c2f88b79a2d3a87975bd740327722a98",
                "sha256": "3339a08796bd9a86c6937e86a8e4b02ea527b559f70d9bac11b600750125d0bf"
            },
            "downloads": -1,
            "filename": "msg2bytes-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c2f88b79a2d3a87975bd740327722a98",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8931,
            "upload_time": "2023-09-14T12:41:00",
            "upload_time_iso_8601": "2023-09-14T12:41:00.283548Z",
            "url": "https://files.pythonhosted.org/packages/41/93/04d59d00e5f200950be7b3b88e089bfbe52f735fa56b38f9d01c29324016/msg2bytes-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8168b81ec588651eaa6e6b0bb75bc763d6e3ffc9f8e8a393667ccb5246596823",
                "md5": "0b260a122b6633e340c7cb1f8d2df66c",
                "sha256": "b5d2d9da5d5fd6185a0a41df983c73068a002c0bf666b6bfd865dc81fece71ae"
            },
            "downloads": -1,
            "filename": "msg2bytes-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "0b260a122b6633e340c7cb1f8d2df66c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9893,
            "upload_time": "2023-09-14T12:41:02",
            "upload_time_iso_8601": "2023-09-14T12:41:02.284956Z",
            "url": "https://files.pythonhosted.org/packages/81/68/b81ec588651eaa6e6b0bb75bc763d6e3ffc9f8e8a393667ccb5246596823/msg2bytes-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-14 12:41:02",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "msg2bytes"
}
        
Elapsed time: 0.57648s