cppumap


Namecppumap JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/cppumap
SummaryC++ unordered map for Python
upload_time2024-09-07 17:33:15
maintainerNone
docs_urlNone
authorJohannes Fischer
requires_pythonNone
licenseMIT
keywords c++ map
VCS
bugtrack_url
requirements Cython list_all_files_recursively numpy setuptools
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# C++ unordered map for Python

### Tested against Windows 10 / Python 3.11 / Anaconda / C++ 20 - MSVC

### pip install cppumap

### Cython and a C++ compiler must be installed!

```PY
from cppumap.um_int__int import Um_int_int
import numpy as np

di = {k: k + 1 for k in range(100)}
di2 = {k: k - 100 for k in range(100, 200)}
stufftodeletelater = list(di2.items())
di.update(di2)
m = Um_int_int(di)
print(m)
stufftodelete = list(range(20))
del m[stufftodelete]
print(m)
values2delete = list(range(90, 100))
m.del_by_values(values2delete)
print(m)
m.del_by_values(79)
print(m)
m.del_by_key_and_value(stufftodeletelater)
print(m)
a = np.arange(100, dtype=np.int32)
b = np.arange(100, dtype=np.int32)
m.set_np(a, b)
print(m)
tuplelist = [(k, k + 1) for k in range(300, 400)]
m.set_tuple_list(tuplelist)
print(m)
print(m.getitems(a))
print(m.sorted())
for k, v in m.items():
    print(k, v)
for k in m:
    print(k)
print(m.keys())
print(m.values())
di3 = {k: k - 100 for k in range(1000, 1200)}
m.update(di3)
print(m)
cop = m.copy()
print(cop)
m.append(100000 - 1, 1)
print(m)

my_results_apply_as_c_function = []
my_results_apply_as_c_pyfunction = []
my_results_apply_as_c_function_nogil = []



def apply_as_c_function(a):
    my_results_apply_as_c_function.append(a)


def apply_as_c_pyfunction(a):
    my_results_apply_as_c_pyfunction.append(a)


def apply_function(a, b):
    return b, a


def apply_as_c_function_nogil(a):
    my_results_apply_as_c_function_nogil.append(a)  # might not release the gil


results1 = m.apply_function(apply_function)
print(results1)
m.apply_as_c_function(apply_as_c_function)
n2 = (
    np.array([q for q in my_results_apply_as_c_function if q is not None], dtype=np.uint64)
    .view(np.int32)
    .reshape((-1, 2))
)
m.apply_as_c_pyfunction(apply_as_c_pyfunction)

n1 = (
    np.array(
        [q for q in my_results_apply_as_c_pyfunction if q is not None], dtype=np.uint64
    )
    .view(np.int32)
    .reshape((-1, 2))
)

m.apply_as_c_function_nogil(apply_as_c_function_nogil)
n3 = (
    np.array(
        [q for q in my_results_apply_as_c_function_nogil if q is not None],
        dtype=np.uint64,
    )
    .view(np.int32)
    .reshape((-1, 2))
)
m.pop(9999)


```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/cppumap",
    "name": "cppumap",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "c++, map",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/51/4c/b33bee6a93ac0ffbe34d9ce4f278bf1c3e4cd5e2088d0628ffccf4ce9fa8/cppumap-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# C++ unordered map for Python\r\n\r\n### Tested against Windows 10 / Python 3.11 / Anaconda / C++ 20 - MSVC\r\n\r\n### pip install cppumap\r\n\r\n### Cython and a C++ compiler must be installed!\r\n\r\n```PY\r\nfrom cppumap.um_int__int import Um_int_int\r\nimport numpy as np\r\n\r\ndi = {k: k + 1 for k in range(100)}\r\ndi2 = {k: k - 100 for k in range(100, 200)}\r\nstufftodeletelater = list(di2.items())\r\ndi.update(di2)\r\nm = Um_int_int(di)\r\nprint(m)\r\nstufftodelete = list(range(20))\r\ndel m[stufftodelete]\r\nprint(m)\r\nvalues2delete = list(range(90, 100))\r\nm.del_by_values(values2delete)\r\nprint(m)\r\nm.del_by_values(79)\r\nprint(m)\r\nm.del_by_key_and_value(stufftodeletelater)\r\nprint(m)\r\na = np.arange(100, dtype=np.int32)\r\nb = np.arange(100, dtype=np.int32)\r\nm.set_np(a, b)\r\nprint(m)\r\ntuplelist = [(k, k + 1) for k in range(300, 400)]\r\nm.set_tuple_list(tuplelist)\r\nprint(m)\r\nprint(m.getitems(a))\r\nprint(m.sorted())\r\nfor k, v in m.items():\r\n    print(k, v)\r\nfor k in m:\r\n    print(k)\r\nprint(m.keys())\r\nprint(m.values())\r\ndi3 = {k: k - 100 for k in range(1000, 1200)}\r\nm.update(di3)\r\nprint(m)\r\ncop = m.copy()\r\nprint(cop)\r\nm.append(100000 - 1, 1)\r\nprint(m)\r\n\r\nmy_results_apply_as_c_function = []\r\nmy_results_apply_as_c_pyfunction = []\r\nmy_results_apply_as_c_function_nogil = []\r\n\r\n\r\n\r\ndef apply_as_c_function(a):\r\n    my_results_apply_as_c_function.append(a)\r\n\r\n\r\ndef apply_as_c_pyfunction(a):\r\n    my_results_apply_as_c_pyfunction.append(a)\r\n\r\n\r\ndef apply_function(a, b):\r\n    return b, a\r\n\r\n\r\ndef apply_as_c_function_nogil(a):\r\n    my_results_apply_as_c_function_nogil.append(a)  # might not release the gil\r\n\r\n\r\nresults1 = m.apply_function(apply_function)\r\nprint(results1)\r\nm.apply_as_c_function(apply_as_c_function)\r\nn2 = (\r\n    np.array([q for q in my_results_apply_as_c_function if q is not None], dtype=np.uint64)\r\n    .view(np.int32)\r\n    .reshape((-1, 2))\r\n)\r\nm.apply_as_c_pyfunction(apply_as_c_pyfunction)\r\n\r\nn1 = (\r\n    np.array(\r\n        [q for q in my_results_apply_as_c_pyfunction if q is not None], dtype=np.uint64\r\n    )\r\n    .view(np.int32)\r\n    .reshape((-1, 2))\r\n)\r\n\r\nm.apply_as_c_function_nogil(apply_as_c_function_nogil)\r\nn3 = (\r\n    np.array(\r\n        [q for q in my_results_apply_as_c_function_nogil if q is not None],\r\n        dtype=np.uint64,\r\n    )\r\n    .view(np.int32)\r\n    .reshape((-1, 2))\r\n)\r\nm.pop(9999)\r\n\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "C++ unordered map for Python",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/cppumap"
    },
    "split_keywords": [
        "c++",
        " map"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4012d0790aee94d5d16b95b11b284f946f6d8ccdaef4bd9415954ba5c531cba7",
                "md5": "29f1a1649dd795495227dd393c1098c3",
                "sha256": "82156370625509443b09477cdcf4b06069aa5556b285d77828603a21737accc0"
            },
            "downloads": -1,
            "filename": "cppumap-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "29f1a1649dd795495227dd393c1098c3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 27856,
            "upload_time": "2024-09-07T17:33:13",
            "upload_time_iso_8601": "2024-09-07T17:33:13.587703Z",
            "url": "https://files.pythonhosted.org/packages/40/12/d0790aee94d5d16b95b11b284f946f6d8ccdaef4bd9415954ba5c531cba7/cppumap-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "514cb33bee6a93ac0ffbe34d9ce4f278bf1c3e4cd5e2088d0628ffccf4ce9fa8",
                "md5": "a8e985659792b4e82f890c19ee0f3ceb",
                "sha256": "d36a9b4952359636c6558269f2ed6305e660057f78cf77a38829a3bec3761183"
            },
            "downloads": -1,
            "filename": "cppumap-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "a8e985659792b4e82f890c19ee0f3ceb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 26803,
            "upload_time": "2024-09-07T17:33:15",
            "upload_time_iso_8601": "2024-09-07T17:33:15.528655Z",
            "url": "https://files.pythonhosted.org/packages/51/4c/b33bee6a93ac0ffbe34d9ce4f278bf1c3e4cd5e2088d0628ffccf4ce9fa8/cppumap-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-07 17:33:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "cppumap",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "Cython",
            "specs": []
        },
        {
            "name": "list_all_files_recursively",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "setuptools",
            "specs": []
        }
    ],
    "lcname": "cppumap"
}
        
Elapsed time: 0.30746s