A C++ style vector implementation for Python
Project description
cppvector
A C++ style vector implementation for Python.
Installation
pip install cppvector-jediz
v = Vector([1, 2, 3, 4, 5]) print("1. SVO test:", v) for x in [999, 111, 222, 333]: v.push_back(x) print(" After overflow:", v)
# 2. swap + comparison
a = Vector(range(10))
b = Vector([100, 200, 300])
a.swap(b)
print("2. After swap():", a, b)
print(" Equality check:", a == Vector([100, 200, 300]))
# 3. REAL NumPy zero-copy interop
print("\n3. NUMPY ZERO-COPY INTEROP")
nv = NumericVector()
for i in range(10):
nv.push_back(i * 10)
print(" NumericVector:", nv)
arr = np.frombuffer(nv, dtype=np.int64)
print(" NumPy view:", arr)
arr[5] = 9999
print(" After NumPy modify:", list(nv))
# 4. vector<bool>
print("\n4. vector<bool> bit packing")
vb = VectorBool([True, False, True] * 2000)
print(f" {len(vb)} bits → {len(vb._data)} bytes used")
vb[5] = True
print(" First 10:", list(vb)[:10])
# 5. Speed test
print("\n5. 10 million push_back speed test...")
v = Vector()
v.reserve(10_000_000)
start = time.time()
for i in range(10_000_000):
v.push_back(i)
print(f" Done in {time.time() - start:.3f}s")
# 6. Shrink back to SVO
while len(v) > 5:
v.pop_back()
v.shrink_to_fit()
print("6. Shrunk to SVO:", v)
## Features
- Dynamic array with automatic resizing
- C++ STL vector-like interface
- Efficient memory management
## License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cppvector_jediz-0.1.1.tar.gz
(5.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cppvector_jediz-0.1.1.tar.gz.
File metadata
- Download URL: cppvector_jediz-0.1.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b68d7f8b465bf1af4e267e252e5a236065219fd23f676dfd9bf7f9dfbb01250
|
|
| MD5 |
f0f98ec0b7324209821b5309a3dfc578
|
|
| BLAKE2b-256 |
d765ec3ba84da2b170ffda76edaac84fcb2839380be67ad0d95d0f0551481f4f
|
File details
Details for the file cppvector_jediz-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cppvector_jediz-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6623e37782c7248c74ca2bad2bd758691a95c2b0c04bdc62c8cbd62a361ac446
|
|
| MD5 |
a79b3d3126d74fa17795735500df5277
|
|
| BLAKE2b-256 |
6a890dec90f0a3cc8ae8afdc35a938e144015a9744f90c8e311b80cfbe986343
|