https://github.com/pmundt/pyrefcount
reference counting API for python, modelled after the Linux Kernel's refcount_t.
https://github.com/pmundt/pyrefcount
python-library refcount reference-counting
Last synced: 12 months ago
JSON representation
reference counting API for python, modelled after the Linux Kernel's refcount_t.
- Host: GitHub
- URL: https://github.com/pmundt/pyrefcount
- Owner: pmundt
- License: mit
- Created: 2020-12-28T11:03:22.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-28T18:45:25.000Z (about 5 years ago)
- Last Synced: 2025-02-02T20:46:59.601Z (about 1 year ago)
- Topics: python-library, refcount, reference-counting
- Language: Python
- Homepage: https://pmundt.github.io/pyrefcount/
- Size: 2.95 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
pyrefcount
==========
|build| |license| |python-version| |pypi-version|
.. |build| image:: https://img.shields.io/github/workflow/status/pmundt/pyrefcount/Python%20package
:alt: GitHub Workflow Status
:target: https://github.com/pmundt/pyrefcount/actions
.. |license| image:: https://img.shields.io/pypi/l/pyrefcount
:alt: MIT License
.. |python-version| image:: https://img.shields.io/pypi/pyversions/pyrefcount
:alt: PyPI - Python Version
:target: https://pypi.python.org/pypi/pyrefcount
.. |pypi-version| image:: https://img.shields.io/pypi/v/pyrefcount
:alt: PyPI
:target: https://pypi.python.org/pypi/pyrefcount
``pyrefcount`` provides a simple API for reference counting, providing protected access to reference counted values,
and for allowing acquire/release actions to be carried out when a reference count becomes active, or the last user
drops off, respectively. ``pyrefcount`` is inspired by the Linux Kernel's `refcount_t`_ API.
Usage
-----
Usage of pyrefcount is straightforward:
>>> from refcount import Refcounter
>>> ref = Refcounter()
>>> ref.inc()
>>> ref.usecount
2
>>> ref.dec()
>>> if ref.dec_and_test():
... print('refcount is now 0, do something here')
For more complex usage examples and a complete API reference, refer to the `package documentation`_.
Features and Bugs
-----------------
Please file feature requests and bug reports in the `issue tracker`_.
License
-------
``pyrefcount`` is licensed under the MIT license.
.. _package documentation: https://pmundt.github.io/pyrefcount
.. _refcount_t: https://github.com/torvalds/linux/blob/master/include/linux/refcount.h
.. _issue tracker: https://github.com/pmundt/pyrefcount/issues