Skip to main content

shared-memory-deque

readme

StaticQueue class memes the collections.deque interface. The goal for this class was to improve performance of mp.Queue class.

Outcome: shared-memory-deque is slower than the classic mp.Queue. The supplied implementation is limited to static size per item and bytes only. Pickling is not included and needs to be done in front. So I dropped the idea and did not finalize. One clear advantage is the pickle-ability of shared-memory-deque. So it can be easily invoked anywhere without the need to inherit from the process spwan/fork.

install

pip install shared-memory-deque

usage

from shared_memory_deque import StaticDeque
deque = StaticDeque(10, 2)
deque.append(b"ed")
deque.pop()

bottle neck

I found that the memoryview assignment of large chunk size is the most time-consuming. A possible workaround could to have a second data object which is build counter-wise. so that one could do a pop_left as a pop from a reversed(data) Another solution could be to just ignore the leading bytes until the memory chunk is consumed with data. When put then a new block is created and assigned. One could use a first pointer.

Function: pop_left at line 72

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
    72                                               def pop_left(self):
    73     10000     441134.0     44.1      6.3          if not self.is_empty:
    74     10000     228660.0     22.9      3.3              res = self.data.buf[:self.length].tobytes()
    75     10000    5496619.0    549.7     78.8              self.data.buf[:self._memsize - self.length] = self.data.buf[self.length:self._memsize]
    76     10000     754754.0     75.5     10.8              self.last = self.last - self.length
    77     10000      53957.0      5.4      0.8              return res
    78                                                   else:
    79                                                       raise Empty

future

Not sure if I will add more free time to this little project. So don't use this module for production or anything else half ways serious.

Copyright © 2022 Simon Bauer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for shared-memory-deque 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shared-memory-deque 0.1
File Size Uploaded Provenance Actions
shared-memory-deque-0.1.tar.gz 5.0 kB Without provenance Details for shared-memory-deque-0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shared-memory-deque 0.1
File Interpreter ABI Platform Actions
shared_memory_deque-0.1-py3-none-any.whl Python 3 none any Details for shared_memory_deque-0.1-py3-none-any.whl

Total release size: 10.2 kB

Release files / shared-memory-deque-0.1.tar.gz

Download URL shared-memory-deque-0.1.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4fd61f9f0c1eb4dcffc0584645432ec1b888da1fa26828f41cea9c702fb9c45a
BLAKE2b-256 checksum
How to use checksums
51928eb4d7e7a86fbe4ae7d82dc71dfbacda300afe6cb78c8ef67251b38d9422
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.0

Release files / shared_memory_deque-0.1-py3-none-any.whl

Download URL shared_memory_deque-0.1-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a889a974f3da6401842987965b75fdaf7ad93d8efff8745399e966a1f6a31b7f
BLAKE2b-256 checksum
How to use checksums
5f2d58e215352766647c5fad6abb5b42df6c20b7e06f8433814babab89985ca6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.0

Security for shared-memory-deque 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page