memorywrapper


Namememorywrapper JSON
Version 0.0.1 PyPI version JSON
download
home_page
SummaryWrapping non-continuous buffers in a late-resolving slice'able buffer-compatible object
upload_time2024-01-13 22:17:44
maintainer
docs_urlNone
author
requires_python>=3.12
licenseMIT License Copyright (c) 2024 Pierre LeMoine Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords buffer memoryview memory bytes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # memorywrapper

`MemoryWrapper` provides a slice-able front-end for a list of non-continuous memory backends, and only
 joins the needed area into a `bytes` object as needed.

It uses the new `__buffer__` protocol that is implementable in python starting with [python 3.12](https://docs.python.org/3.12/reference/datamodel.html?highlight=__buffer_#emulating-buffer-types).

## Installing

`pip install memorywrapper`

## Using

```py
    >>> from memorywrapper import MemoryWrapper
    >>> import struct
    >>> memory = MemoryWrapper([b"\x01\x02\x03", bytes([4,5,6])])
    >>> part = memory[1:-1]
    >>> (value,) = struct.unpack(">I", part)
    >>> f"0x{value:08x}"
    '0x02030405'
```

### make_slices

`make_slices` provides a way to cut something like bytes, memoryview, or memorywrapper into equal-sized chunks.

```py
    >>> from memorywrapper import make_slices
    >>> list(make_slices([1,2,3,4,5,6,7,8,9], 3))
    [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
```


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "memorywrapper",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": "",
    "keywords": "buffer,memoryview,memory,bytes",
    "author": "",
    "author_email": "Pierre LeMoine <pypi@luben.se>",
    "download_url": "https://files.pythonhosted.org/packages/3c/66/75a947f44cd04fcb37b898e6bc4e5e051fdd8b4fc16761a2f55723d772d4/memorywrapper-0.0.1.tar.gz",
    "platform": null,
    "description": "# memorywrapper\n\n`MemoryWrapper` provides a slice-able front-end for a list of non-continuous memory backends, and only\n joins the needed area into a `bytes` object as needed.\n\nIt uses the new `__buffer__` protocol that is implementable in python starting with [python 3.12](https://docs.python.org/3.12/reference/datamodel.html?highlight=__buffer_#emulating-buffer-types).\n\n## Installing\n\n`pip install memorywrapper`\n\n## Using\n\n```py\n    >>> from memorywrapper import MemoryWrapper\n    >>> import struct\n    >>> memory = MemoryWrapper([b\"\\x01\\x02\\x03\", bytes([4,5,6])])\n    >>> part = memory[1:-1]\n    >>> (value,) = struct.unpack(\">I\", part)\n    >>> f\"0x{value:08x}\"\n    '0x02030405'\n```\n\n### make_slices\n\n`make_slices` provides a way to cut something like bytes, memoryview, or memorywrapper into equal-sized chunks.\n\n```py\n    >>> from memorywrapper import make_slices\n    >>> list(make_slices([1,2,3,4,5,6,7,8,9], 3))\n    [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Pierre LeMoine  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Wrapping non-continuous buffers in a late-resolving slice'able buffer-compatible object",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/DrInfiniteExplorer/py-memorywrapper",
        "Repository": "https://github.com/DrInfiniteExplorer/py-memorywrapper"
    },
    "split_keywords": [
        "buffer",
        "memoryview",
        "memory",
        "bytes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "660f51d3ba4249e8fe0881bc5fcca656374c473455e51f44000eba875e9b6292",
                "md5": "b4f0bacbd721ec5061b5f175abf2f245",
                "sha256": "1f45600d9f5758723ce9489335c42c35462dc6eb81079aa2c8c60fae3e62629c"
            },
            "downloads": -1,
            "filename": "memorywrapper-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b4f0bacbd721ec5061b5f175abf2f245",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 5295,
            "upload_time": "2024-01-13T22:17:43",
            "upload_time_iso_8601": "2024-01-13T22:17:43.129240Z",
            "url": "https://files.pythonhosted.org/packages/66/0f/51d3ba4249e8fe0881bc5fcca656374c473455e51f44000eba875e9b6292/memorywrapper-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3c6675a947f44cd04fcb37b898e6bc4e5e051fdd8b4fc16761a2f55723d772d4",
                "md5": "a18a4981ca309bb42f7eee857059df9e",
                "sha256": "54299d3b0c104a76c467a91df55f164aa47329f6ec7a25101cd5c6b1fdfceb08"
            },
            "downloads": -1,
            "filename": "memorywrapper-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a18a4981ca309bb42f7eee857059df9e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 7584,
            "upload_time": "2024-01-13T22:17:44",
            "upload_time_iso_8601": "2024-01-13T22:17:44.409672Z",
            "url": "https://files.pythonhosted.org/packages/3c/66/75a947f44cd04fcb37b898e6bc4e5e051fdd8b4fc16761a2f55723d772d4/memorywrapper-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-13 22:17:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DrInfiniteExplorer",
    "github_project": "py-memorywrapper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "memorywrapper"
}
        
Elapsed time: 0.16819s