CSTL


NameCSTL JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/fuzihaofzh/CSTL
SummaryThe C++ Standard Template Library (STL) for Python
upload_time2023-03-20 09:38:41
maintainer
docs_urlNone
author
requires_python
license
keywords c++ stl list dict set
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CSTL : The C++ Standard Template Library (STL) for Python

In this `CSTL` tool, we wrap several C++ STL containers to use in Python. The containers use native C++ implementation and will not have the [copy on write](https://en.wikipedia.org/wiki/Copy-on-write) issue like native `list`, and `dict` in Python. Though it is designed to solve the CoW issue, it can also be used in scenarios where a standard C++ container is needed.

## Install
Install from `pip`:
```
pip install CSTL
```
Build from source:
```
git clone https://github.com/fuzihaofzh/CSTL.git
cd CSTL
./build.sh
python setup.py install --single-version-externally-managed --record files.txt
```

## Usage 
```python
import CSTL
vec = CSTL.VecInt([1,2,3,4,5,6,7])
print(vec[2])      #3
vec[2] = 1
print(vec[2])      #1
vec.append(10)
print(vec[-1])     #10
print(list(vec))   #[1, 2, 1, 4, 5, 6, 7, 10]
```

## Supported Datatype

We support the following data types as the elements in the containers
|Python Type|C++ Type| Can be dict key|
|---|---|---|
|int|int|Yes|
|int|std::int64|Yes|
|str|std::string|Yes|
|float|float|No|
|double|double|No|
|bool|bool|No|

## Supported Containers
The supported containers are listed as follows
|Python Structure|C++ Container| 
|---|---|
|list|std::vector|
|dict|std::unordered_map|
|set|std::unordered_set|

We also support nested container, namely, structure like `std::unordered_map< std::string,std::unordered_map< std::string,std::vector< bool > > >` is supported. Currently, at most 3 nested layers are supported.

## Copy on Write Issue in Python
This is a feature not a bug for Python. In multi-processing programs, the shared object will be copied to each process if they access the data. However, if the data is large and we use several processes, the memory cannot hold a separate copy for each process. This cannot be solved in Python as all Python's native structures with ref count have such problems. A more detailed discussion can be found at https://github.com/pytorch/pytorch/issues/13246 .





            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/fuzihaofzh/CSTL",
    "name": "CSTL",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "C++ STL List Dict Set",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/90/df/9da320429cc2cff290214c6466e773dddcb9125a079c24812d5091ebc03d/CSTL-0.0.2.tar.gz",
    "platform": null,
    "description": "# CSTL : The C++ Standard Template Library (STL) for Python\n\nIn this `CSTL` tool, we wrap several C++ STL containers to use in Python. The containers use native C++ implementation and will not have the [copy on write](https://en.wikipedia.org/wiki/Copy-on-write) issue like native `list`, and `dict` in Python. Though it is designed to solve the CoW issue, it can also be used in scenarios where a standard C++ container is needed.\n\n## Install\nInstall from `pip`:\n```\npip install CSTL\n```\nBuild from source:\n```\ngit clone https://github.com/fuzihaofzh/CSTL.git\ncd CSTL\n./build.sh\npython setup.py install --single-version-externally-managed --record files.txt\n```\n\n## Usage \n```python\nimport CSTL\nvec = CSTL.VecInt([1,2,3,4,5,6,7])\nprint(vec[2])      #3\nvec[2] = 1\nprint(vec[2])      #1\nvec.append(10)\nprint(vec[-1])     #10\nprint(list(vec))   #[1, 2, 1, 4, 5, 6, 7, 10]\n```\n\n## Supported Datatype\n\nWe support the following data types as the elements in the containers\n|Python Type|C++ Type| Can be dict key|\n|---|---|---|\n|int|int|Yes|\n|int|std::int64|Yes|\n|str|std::string|Yes|\n|float|float|No|\n|double|double|No|\n|bool|bool|No|\n\n## Supported Containers\nThe supported containers are listed as follows\n|Python Structure|C++ Container| \n|---|---|\n|list|std::vector|\n|dict|std::unordered_map|\n|set|std::unordered_set|\n\nWe also support nested container, namely, structure like `std::unordered_map< std::string,std::unordered_map< std::string,std::vector< bool > > >` is supported. Currently, at most 3 nested layers are supported.\n\n## Copy on Write Issue in Python\nThis is a feature not a bug for Python. In multi-processing programs, the shared object will be copied to each process if they access the data. However, if the data is large and we use several processes, the memory cannot hold a separate copy for each process. This cannot be solved in Python as all Python's native structures with ref count have such problems. A more detailed discussion can be found at https://github.com/pytorch/pytorch/issues/13246 .\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "The C++ Standard Template Library (STL) for Python",
    "version": "0.0.2",
    "split_keywords": [
        "c++",
        "stl",
        "list",
        "dict",
        "set"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0623283b1aa7139a57ce359ceab548969462d42748df41ee8153d1442ac9e62b",
                "md5": "09105f745309a843fb321af5559ae257",
                "sha256": "17c0fff9573e86be9760200d149b2caab82f67744528cbdfa14151ad4b84d190"
            },
            "downloads": -1,
            "filename": "CSTL-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "09105f745309a843fb321af5559ae257",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5191134,
            "upload_time": "2023-03-20T09:38:38",
            "upload_time_iso_8601": "2023-03-20T09:38:38.114817Z",
            "url": "https://files.pythonhosted.org/packages/06/23/283b1aa7139a57ce359ceab548969462d42748df41ee8153d1442ac9e62b/CSTL-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90df9da320429cc2cff290214c6466e773dddcb9125a079c24812d5091ebc03d",
                "md5": "426ffd9df5884f755a47f0501b5e7d6c",
                "sha256": "d6a26221343239c36946f1b1abfebaaefe8165eb525f71f5f3b55d69bed1b669"
            },
            "downloads": -1,
            "filename": "CSTL-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "426ffd9df5884f755a47f0501b5e7d6c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5082087,
            "upload_time": "2023-03-20T09:38:41",
            "upload_time_iso_8601": "2023-03-20T09:38:41.230340Z",
            "url": "https://files.pythonhosted.org/packages/90/df/9da320429cc2cff290214c6466e773dddcb9125a079c24812d5091ebc03d/CSTL-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-20 09:38:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "fuzihaofzh",
    "github_project": "CSTL",
    "lcname": "cstl"
}
        
Elapsed time: 0.04804s