pymembar 0.0.2__cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
membar/__init__.py ADDED
@@ -0,0 +1,11 @@
1
+ # Import the C extension module and expose its functions
2
+ try:
3
+ from ._membar import wmb, rmb, fence # Import from private C extension
4
+ __all__ = ['wmb', 'rmb', 'fence']
5
+ except ImportError as e:
6
+ # Fallback error message if the C extension cannot be imported
7
+ raise ImportError(f"Could not import C extension module: {e}")
8
+
9
+ # do NOT alter the following line in any way EXCEPT changing
10
+ # the version number. no comments, no rename, whatsoever
11
+ __version__ = "0.0.2"
membar/__init__.pyi ADDED
@@ -0,0 +1,32 @@
1
+ """
2
+ Type stubs for membar module - Memory barrier utilities for Python
3
+ """
4
+
5
+ def wmb() -> None:
6
+ """
7
+ Write memory barrier.
8
+
9
+ Ensures that all write operations issued before this barrier
10
+ are completed before any write operations issued after this barrier.
11
+ """
12
+ ...
13
+
14
+ def rmb() -> None:
15
+ """
16
+ Read memory barrier.
17
+
18
+ Ensures that all read operations issued before this barrier
19
+ are completed before any read operations issued after this barrier.
20
+ """
21
+ ...
22
+
23
+ def fence() -> None:
24
+ """
25
+ Full memory fence.
26
+
27
+ Ensures that all memory operations (both reads and writes) issued before
28
+ this barrier are completed before any memory operations issued after this barrier.
29
+ """
30
+ ...
31
+
32
+ __all__ = ['wmb', 'rmb', 'fence']
membar/py.typed ADDED
File without changes
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: pymembar
3
+ Version: 0.0.2
4
+ Summary: Memory barrier utilities for Python - provides wmb, rmb, and fence operations
5
+ Author-email: fwkrumm <fwkrumm@github.com>
6
+ Maintainer-email: fwkrumm <fwkrumm@github.com>
7
+ Project-URL: Homepage, https://github.com/fwkrumm/pymembar
8
+ Project-URL: Repository, https://github.com/fwkrumm/pymembar
9
+ Project-URL: Issues, https://github.com/fwkrumm/pymembar/issues
10
+ Project-URL: Documentation, https://github.com/fwkrumm/pymembar/blob/master/README.md
11
+ Keywords: memory-barriers,concurrency,low-level,synchronization,threading
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: C
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Classifier: Topic :: System :: Hardware
27
+ Classifier: Topic :: System :: Operating System
28
+ Classifier: Typing :: Typed
29
+ Requires-Python: >=3.8
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE.txt
32
+ Dynamic: license-file
33
+
34
+ # Python Memory Barrier (pymembar)
35
+
36
+ Memory barrier utilities for Python - provides low-level memory ordering primitives for concurrent programming. Usually you would not need this in Python due to GIL and generally strong memory ordering on x86/x86_64. However, on weakly-ordered architectures like ARM, memory barriers can be useful for ensuring correct visibility and ordering of memory operations when for example working with shared memory, named semaphores, or lock-free data structures.
37
+
38
+ I used AI (GitHub Copilot) to help generate parts of this README, documentation strings, and some configuration files. Please report any inaccuracies or errors you may find.
39
+
40
+
41
+ ## Overview
42
+
43
+ This package provides Python bindings for memory barrier operations, ensuring that memory operations are visible to other processes and threads in the correct order. Memory barriers do not provide synchronization themselves, but rather control the visibility and ordering of memory operations across CPU cores and processes.
44
+
45
+ The package includes three core functions:
46
+
47
+ - `wmb()` - Write memory barrier
48
+ - `rmb()` - Read memory barrier
49
+ - `fence()` - Full memory fence
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ pip install pymembar
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ ```python
60
+ import membar
61
+
62
+ # Write memory barrier - ensures all write operations before this point
63
+ # are visible to other processes/threads before any writes after this point
64
+ membar.wmb()
65
+
66
+ # Read memory barrier - ensures all read operations before this point
67
+ # complete before any read operations after this point
68
+ membar.rmb()
69
+
70
+ # Full memory fence - ensures all memory operations before this point
71
+ # are visible to other processes/threads before any operations after this point
72
+ membar.fence()
73
+ ```
74
+
75
+ ## When Are Memory Barriers Needed?
76
+
77
+ Memory barriers are primarily needed on weakly-ordered CPU architectures like ARM, where the processor may reorder memory operations for performance optimization. On x86/x86_64 architectures, the strong memory ordering model means that memory barriers are often not strictly necessary for most use cases, as the hardware already provides strong ordering guarantees.
78
+
79
+ However, memory barriers can still be useful on x86 in specific scenarios:
80
+ - When interfacing with memory-mapped I/O
81
+ - In lock-free programming with specific compiler optimizations
82
+ - When precise ordering is critical for correctness
83
+
84
+ **Note:** Most Python applications will not need memory barriers due to the Global Interpreter Lock (GIL) and Python's threading model.
85
+
86
+ ## Requirements
87
+
88
+ - Python 3.8+
89
+ - Compatible with Windows, Linux, and macOS
90
+
91
+ ## Contributing
92
+
93
+ I am not a C expert and would be happy to receive any constructive feedback, suggestions, or contributions to improve this library. Feel free to open issues or submit pull requests on the [GitHub repository](https://github.com/fwkrumm/pymembar).
94
+
95
+ ## Disclaimer
96
+
97
+ Parts of the core code, this README, and documentation strings were generated with AI assistance.
98
+
99
+
100
+ # TODOs
101
+ - Is it possible to write tests for the functionality
102
+ - Add ARM build to CI/CD pipeline as soon as they are available via GitHub Actions
@@ -0,0 +1,9 @@
1
+ membar/__init__.py,sha256=0iiqRV-gtAQFLIOdcXVPWfpIfb9wCLpLc6MnyH_TxOs,476
2
+ membar/__init__.pyi,sha256=glQKrU-Ip7Dktd_o4sADHqcGfpq3VF1K_djueMbTyNI,759
3
+ membar/_membar.cpython-311-aarch64-linux-gnu.so,sha256=LBC_7s1uA1jvA5tI9LyVdLkE2GOBiP5GIIX50qWcPG4,212240
4
+ membar/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ pymembar-0.0.2.dist-info/METADATA,sha256=L4z0m3DJP0pJdoEvnr_6DKrP8pXc-zjTgQpR4EhXJEs,4572
6
+ pymembar-0.0.2.dist-info/WHEEL,sha256=nENvFvUt2sTxh7qTwFTbrHft1Jd6WkcTog-2x3-pWGY,193
7
+ pymembar-0.0.2.dist-info/top_level.txt,sha256=FTuLb28Ianih6q3VxqZmPeRo7ppIhVkSpLcVkbNrxow,7
8
+ pymembar-0.0.2.dist-info/RECORD,,
9
+ pymembar-0.0.2.dist-info/licenses/LICENSE.txt,sha256=D5tHuFx3CsUmFQTursu3R7LmOAgCWqlytpquqGKWXdY,1499
@@ -0,0 +1,7 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp311-cp311-manylinux_2_17_aarch64
5
+ Tag: cp311-cp311-manylinux2014_aarch64
6
+ Tag: cp311-cp311-manylinux_2_28_aarch64
7
+
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024, Fabian Krumm
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1 @@
1
+ membar