Skip to main content

Fast single ended queue library for python

Project description

fastqueue

Tests PyPI versions PyPI license
PyPI

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

Queue_times Queue_types_linux

Windows

Queue_times Queue_types

Iteration

Ubuntu

Iterable_Instantiation Iterable_Iteration

Windows

Iterable_Instantiation Iterable_Iteration

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

fastqueue-lib-0.0.14.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

fastqueue_lib-0.0.14-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (62.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

File details

Details for the file fastqueue-lib-0.0.14.tar.gz.

File metadata

  • Download URL: fastqueue-lib-0.0.14.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for fastqueue-lib-0.0.14.tar.gz
Algorithm Hash digest
SHA256 4293a0a3138eadf1a432c55a17fb3b810f92da1c28d3ac28173fa62bf2d47f7c
MD5 b638294fb6f04cef548eb6043e71fe67
BLAKE2b-256 8cffe1b13e5f3b12e7fdc4d3bcb05955c273676f6b7905ede8f3cf1168a1b93b

See more details on using hashes here.

File details

Details for the file fastqueue_lib-0.0.14-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for fastqueue_lib-0.0.14-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e3d186b730a1d26e39b7affb77f9ff6079a068b9f9699ce0e51b836a13f4ae58
MD5 d61fcdc19eeb3144267c5678cbe1120c
BLAKE2b-256 5a6ba3b247a77400f6d13c8a3754e7cd585b86ed8d107916a434148a98b181a6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page