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!
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)
Metadata
Release files for cppumap 0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cppumap-0.10.tar.gz | 26.8 kB | Without provenance | Details for cppumap-0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cppumap-0.10-py3-none-any.whl | Python 3 | none | any | Details for cppumap-0.10-py3-none-any.whl |
Total release size: 54.7 kB
Release files / cppumap-0.10.tar.gz
| Download URL | cppumap-0.10.tar.gz |
|---|---|
| Size | 26.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d36a9b4952359636c6558269f2ed6305e660057f78cf77a38829a3bec3761183
|
|
BLAKE2b-256 checksum How to use checksums |
514cb33bee6a93ac0ffbe34d9ce4f278bf1c3e4cd5e2088d0628ffccf4ce9fa8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / cppumap-0.10-py3-none-any.whl
| Download URL | cppumap-0.10-py3-none-any.whl |
|---|---|
| Size | 27.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82156370625509443b09477cdcf4b06069aa5556b285d77828603a21737accc0
|
|
BLAKE2b-256 checksum How to use checksums |
4012d0790aee94d5d16b95b11b284f946f6d8ccdaef4bd9415954ba5c531cba7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for cppumap 0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.