Fast ordered dict with deque-like operations at both ends
Project description
DequeDict
Ordered dictionary with O(1) deque operations at both ends.
Features
- O(1) key lookup — like
dict - O(1) pop/peek from both ends — like
deque - O(1) appendleft, move_to_end, delete by key
- Full typing support with
.pyistubs
Installation
pip install dequedict
Usage
from dequedict import DequeDict, DefaultDequeDict
dd = DequeDict([("a", 1), ("b", 2), ("c", 3)])
dd["d"] = 4 # Set
value = dd["a"] # Get
del dd["b"] # Delete
dd.peekleft() # First value
dd.popleft() # Remove first
dd.appendleft("z", 0) # Insert at front
dd.move_to_end("a") # Move to back
# DefaultDequeDict: auto-create values like defaultdict
groups = DefaultDequeDict(list)
groups["a"].append(1)
groups["a"].append(2)
API
| Method | Description |
|---|---|
peekleft() / peek() |
First/last value |
peekleftitem() / peekitem() |
First/last (key, value) |
popleft() / pop() |
Remove and return first/last |
popleftitem() / popitem() |
Remove and return first/last pair |
appendleft(key, value) |
Insert at front |
move_to_end(key, last=True) |
Move to front or back |
get, keys, values, items, clear, copy, update, setdefault |
Standard dict ops |
Performance
Mac M1, Python 3.11, C extension:
| Operation | DequeDict | dict | deque | OrderedDict |
|---|---|---|---|---|
| Key lookup | 32 ns | 23 ns | O(n) | 24 ns |
| Peek left | 22 ns | N/A | 23 ns | 59 ns |
| Peek right | 22 ns | N/A | 23 ns | 70 ns |
| Pop left ×100 | 3.7 µs | N/A | 2.1 µs | 7.7 µs |
| Delete by key ×100 | 4.3 µs | 2.8 µs | O(n) | 6.0 µs |
| Insert ×100 | 6.6 µs | 9.5 µs | N/A | 6.8 µs |
Pop is ~1.8x slower than deque due to dict maintenance, but provides O(1) key lookup.
Benchmarks
python benchmarks/benchmark.py
Tests
pip install pytest
python -m pytest tests/ -v
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 dequedict-0.1.1.tar.gz.
File metadata
- Download URL: dequedict-0.1.1.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23655292a32fa9b5417790056c1441d808f8e495b5652826716f205958463987
|
|
| MD5 |
d4fc4d35bf31e8b149462dc448c652c5
|
|
| BLAKE2b-256 |
9360031f9f517199ab6765e33d74b1f662f87887938cc319b59d00b3fc0341ef
|
File details
Details for the file dequedict-0.1.1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 23.7 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd38d9dd3595e2d490926ab5d83238237b950e527bed04d6082e512ae54e4168
|
|
| MD5 |
bd5a7703f64da94e0397fdec81867b47
|
|
| BLAKE2b-256 |
0a6c7008ee8be0832c64783c61dd46a96fb26ed953df974567b0e8be6695bbc8
|
File details
Details for the file dequedict-0.1.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 52.5 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85499af60b80f5889735a211f591f0da2e54b439920677246b9bbbea72f23220
|
|
| MD5 |
b7fdbdce502e050711f577437965220c
|
|
| BLAKE2b-256 |
7a042db8ce2f3c29092d71e7ce3b79c89ed60d4dc4740123d08f007d171ccbe8
|
File details
Details for the file dequedict-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 21.8 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8d3c1076a3db357235781a52d78b02ef546fb8e92e18748095ec934d545c1a9
|
|
| MD5 |
7e220fa9170f9d94d8643ef018e9054f
|
|
| BLAKE2b-256 |
a22417707c8c6de00fbd4cc93b5a398f6b2bf00387208d58a4fa704b5e66c3cf
|
File details
Details for the file dequedict-0.1.1-cp313-cp313-macosx_10_13_x86_64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp313-cp313-macosx_10_13_x86_64.whl
- Upload date:
- Size: 21.7 kB
- Tags: CPython 3.13, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe1affca71a8c54ccc166e0e5e97a8a8bbef1a46d989afb2ae87634ca3b159b4
|
|
| MD5 |
8509afd8f9d738640a757293053b9e3f
|
|
| BLAKE2b-256 |
db4fe2ad941dd8af98c5fe3a304a81fd13dcfa3fe8c0a86231cdf9f620badf04
|
File details
Details for the file dequedict-0.1.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 23.7 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c63c1a330209d74008ddf99b9c4749a76842a667903f1c356d514de5be078beb
|
|
| MD5 |
df9f18218bd158f61de9fa0ede6fbfd8
|
|
| BLAKE2b-256 |
18012732c4215bd6af27e174d324ed4bb75bac2afc573ff5a5a0a5063ee2ef65
|
File details
Details for the file dequedict-0.1.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 52.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cb7a58c83037e982387e41c9c82fd110bbb2c639acccb798a066f9125174db8
|
|
| MD5 |
6902038b380f25e54d1f20f368b4724c
|
|
| BLAKE2b-256 |
dbb65b683be1d29aa43e2408651b2e06a2b74a4ec285087465b718a54def8956
|
File details
Details for the file dequedict-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 21.8 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a9717cb76198f3d265c727006eb123abe39e3c2fcf1cf92b2a28fd76ba73dd0
|
|
| MD5 |
ec379fa8e9ff312270366bfe75787228
|
|
| BLAKE2b-256 |
148c1cd967c8b320fce231cbbf11ac9d0cead95f8c530fcbdcf809525ebd6294
|
File details
Details for the file dequedict-0.1.1-cp312-cp312-macosx_10_13_x86_64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp312-cp312-macosx_10_13_x86_64.whl
- Upload date:
- Size: 21.7 kB
- Tags: CPython 3.12, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee34c876d0bd1640c4c533e64ba209e58df982e0d4a8376ce5f694318b0554b6
|
|
| MD5 |
d2f99e615d13eb385c20767e61e77bfd
|
|
| BLAKE2b-256 |
5207f0ae21331a7815094c6cd7ca93691e04e93b9cf8db9f715b87d39982537a
|
File details
Details for the file dequedict-0.1.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 23.5 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5f5ddcbf0b169ebf7740b40163151142ee644236c445ab4b9be0ea873d6af47
|
|
| MD5 |
835f2e2ba3f58c40e6910fa956990f6e
|
|
| BLAKE2b-256 |
cc71a7587ddcec6e2457f583ea041bdbef03676d9a8ccb5c321b10adb8739ff6
|
File details
Details for the file dequedict-0.1.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 50.7 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3340684d0c2596360ad465a7207edc96ceba91b1b4fa9c2dfb427840bcea932
|
|
| MD5 |
78243f5b3425a0dc1585706c8bfe5dd4
|
|
| BLAKE2b-256 |
3f8c172581041c198a7b6b76cf91d1dee66a56c6d4fca7b1aefe7b5d30aca361
|
File details
Details for the file dequedict-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 21.8 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ff29015d389583106a3716cac009ed865564581e65998d45b083feed9115580
|
|
| MD5 |
f3b8a1f95fee1730e0fc6056b3ed5200
|
|
| BLAKE2b-256 |
dacdba8170109b33c06109343d365f2e346a843d38bc7a96c9a222e234269abc
|
File details
Details for the file dequedict-0.1.1-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 21.5 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54899060663b295d2cb6c2b9574e42465ba246e53fa5a2e56f0cd6476275eab2
|
|
| MD5 |
c648b4e9b9ba7bbe2a9a7a9bec31f9de
|
|
| BLAKE2b-256 |
e2d9714d2d941dac1ffb3f81f983b52112bdeb42cc2871c778e92224619f278a
|
File details
Details for the file dequedict-0.1.1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 23.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a98cf906e037be658dfd4a8f659d5d3095c03ba193d75c4c0cf25283379716c
|
|
| MD5 |
910cdd448962cca421e18863631a1686
|
|
| BLAKE2b-256 |
3dc2f74f8ad24cafc089e233cc498e446dd49cd005b4190781d39c4633f483f8
|
File details
Details for the file dequedict-0.1.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 49.9 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d208d7f78718b38e72a97e2c6deabea5b40ede9cc97ce570fe4eb7c16e5008f
|
|
| MD5 |
dd9fc5321d565d8c49b2f222cdba93ac
|
|
| BLAKE2b-256 |
c8dc57a0966aaa46ce6fc0a23518f431f763716e19074368af0a9c4ed258db8d
|
File details
Details for the file dequedict-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 21.8 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
363031e3aabf690c7724eb64fb6297da00e337a610203cd1abd65062890b5001
|
|
| MD5 |
9df4f4cf81f22fd500425f73436c28d1
|
|
| BLAKE2b-256 |
815d23310acd480525d454ac778c7366fafb1b8e23445ebeecb6c644b3019879
|
File details
Details for the file dequedict-0.1.1-cp310-cp310-macosx_10_9_x86_64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 21.5 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c832c838a6e14b812fde726296b3d554bce58749d4609bb396b355e97dfa04e
|
|
| MD5 |
bf2510efdfdc17430ee4ab8f26319518
|
|
| BLAKE2b-256 |
e8d8121ded7b8a5e7b8f577dffdcd6db2f2860c759051998d4b12bab6f0794af
|
File details
Details for the file dequedict-0.1.1-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 23.5 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcc0d69a4b9f6ba1461e9b9c6691a0fe0dee7af5eadd47f31bfe5d87f13b6985
|
|
| MD5 |
67279494b263691be357310b1d41740f
|
|
| BLAKE2b-256 |
3848eb8906b1c4cd3008738eab13bcbc9a05e2713d8db02be36352d01c569c7b
|
File details
Details for the file dequedict-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 49.6 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20faf655cb63b4f73d0664d12085b341785a1aef3ebfffa78a28d6a5fccc1399
|
|
| MD5 |
0f33ce7de8a43da456eeaa9545895a73
|
|
| BLAKE2b-256 |
ebddc3a2dead56414b5064ac01b70d3ffc5a5ee14fa71f0ad98b323b4b326c29
|
File details
Details for the file dequedict-0.1.1-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 21.8 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
120836f005ce6ae5ee0214c3854fa20edd5f1f123a546be5198107ac5db7febf
|
|
| MD5 |
c22f10b362b7942f6dcc4272e0e0a2ae
|
|
| BLAKE2b-256 |
15acdaf22550070ca4caeafc80a1824dfbfd60d7236245e3c8e05142e6986e0f
|
File details
Details for the file dequedict-0.1.1-cp39-cp39-macosx_10_9_x86_64.whl.
File metadata
- Download URL: dequedict-0.1.1-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 21.5 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09396848f29ff423c5db22976c46d898cb1f8702dc09950c0ee6d6614b45731a
|
|
| MD5 |
c993f209eea544500fa5980a627bcfee
|
|
| BLAKE2b-256 |
6d7a19f96d19b74c4699328f66e1240769503eac6ef8299d3f77112f01b4e8d9
|