Fast single ended queue library for python
Project description
fastqueue
Single ended fast queue's built in C tuned for python.
Requirements
python 3.7+
Installation
To install fastqueue, using pip:
pip install fastqueue-lib
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)) ]
['🚒', '🛴', '🚅', '🚗']
Another alternative is fastqueue.LockQueue()
which supports all queue operations.
fastqueue.LockQueue()
is built as a thread-safe alternative to the other queue types.
Example Benchmarks
Queue operations
Ubuntu
Windows
Iteration
Ubuntu
Windows
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
Hashes for fastqueue_lib-0.0.13-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa5f6d22803be5d3d0056a49b2a50e1152790b409e5baf835bd66ab2180cba67 |
|
MD5 | 147a0aa490f3f3ed3276fad823c77ccc |
|
BLAKE2b-256 | b9727221abc1733fe19a41aa554499b95a6c2f7953f49134e4a1e9bce5e66fb7 |