Fast single ended queue library for python
Project description
fastqueue
Single ended fast queue's built in C tuned for python.
Requirements
python 3.9+
Installation
To install fastqueue, using pip:
pip install fastqueue
Quickstart
For general use cases fastqueue.Queue()
objects are tuned to perform well.
The enqueue and dequeue methods perform well over a large sequence of arbitrary operations.
fastqueue.Queue()
supports many standard sequence methods similar to lists.
fastqueue.Queue()
minimizes memory usage but maintains the fast queue speeds.
>>> from fastqueue import Queue
>>> queue = Queue()
>>> queue.extend(['🚒', '🛴'])
>>> queue[0]
'🚒'
>>> '🛴' in queue
True
>>> queue.enqueue('🚅')
>>> queue.enqueue('🚗')
>>> queue[-1]
'🚗'
>>> [queue.dequeue() for _ in range(len(queue)) ]
['🚒', '🛴', '🚅', '🚗']
For more specialized cases fastqueue.QueueC()
objects are tuned to perform well.
The interface for fastqueue.QueueC()
is identical to fastqueue.Queue()
.
The enqueue and dequeue methods perform similarly well over a large sequence of arbitrary operations.
fastqueue.QueueC()
handles memory differently by doubling the capacity when full.
This increases the complexity but maintains fast amortized cost.
The benefit of this approach is even faster __getitem__
and __setitem__
speeds
>>> from fastqueue import QueueC
>>> queue_c = QueueC()
>>> queue_c.extend(['🚒', '🛴'])
>>> queue_c[0]
'🚒'
>>> '🛴' in queue_c
True
>>> queue_c.enqueue('🚅')
>>> queue_c.enqueue('🚗')
>>> queue_c[-1]
'🚗'
>>> [queue_c.dequeue() for _ in range(len(queue_c)) ]
['🚒', '🛴', '🚅', '🚗']
Example Benchmarks
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
Built Distribution
File details
Details for the file fastqueue-lib-0.0.2.tar.gz
.
File metadata
- Download URL: fastqueue-lib-0.0.2.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9e78609c39d819ff93e45d41b33385c96fad1627048553cc083c98d51366460 |
|
MD5 | 1fa9bd577cb2f25e0f06bec27596a1c6 |
|
BLAKE2b-256 | db8f9653867b06eeada98fb195e0aa546a10f8135fc88039d6f9801942ce40f9 |
File details
Details for the file fastqueue_lib-0.0.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: fastqueue_lib-0.0.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 49.4 kB
- Tags: CPython 3.10, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da8bef3ac97c84216546c96ff2a2dbd4dec38889b272d9f98377c3921b35ffbe |
|
MD5 | 646cb43c9c6ca21b85f5fa7f6609b65e |
|
BLAKE2b-256 | bb75a07ba58760b92d35e43187fd591146d780ad97ed502a652ada17e27b91c8 |