Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
weakreflist
.. image:: https://pypip.in/v/weakreflist/badge.png :target: https://pypi.python.org/pypi/weakreflist
Table of Contents
.. contents:: :local: :depth: 1 :backlinks: none
Install it from pypi::
pip install weakreflist
or from sources::
git clone git@github.com:apieum/weakreflist.git cd weakreflist python setup.py install
Same as a list except that when a weakref-able variable is deleted, it is removed from the list.
Example for CPython:
.. code-block:: python
from weakreflist import WeakList
class A(object):
"""weakrefs don't function directly on object()"""
objectA = A()
my_list = WeakList([objectA])
assert len(my_list) == 1
del objectA
assert len(my_list) == 0 # objectA removed from list
Note: Pypy (probably jython, cython...) have a different implementation of garbage collector and it is known that weakrefs doesn't function the same way.
You need to explicitly call gc.collect() which has an impact on performance.
Example for other python implementations
.. code-block:: python
from weakreflist import WeakList
import gc
class A(object):
"""weakrefs don't function directly on object()"""
objectA = A()
my_list = WeakList([objectA])
assert len(my_list) == 1
del objectA
assert len(my_list) == 1 # gc not done
gc.collect() # must be called
assert len(my_list) == 0
Your feedback, code review, improvements or bugs, and help to document is appreciated. You can contact me by mail: apieum [at] gmail [dot] com
Test recommended requirements::
pip install -r dev-requirements.txt
Sometimes --spec-color doesn't function. Uninstall nosespec and nosecolor then reinstall nosecolor and nosespec separatly in this order (nosecolor first).
Launch tests::
git clone git@github.com:apieum/weakreflist.git cd weakreflist nosetests --with-spec --spec-color ./weakreflist
Thanks to BoonsNaibot <https://github.com/BoonsNaibot>
_ to have contributed to:
.. image:: https://secure.travis-ci.org/apieum/weakreflist.png?branch=master :target: https://travis-ci.org/apieum/weakreflist
FAQs
A WeakList class for storing objects using weak references in a list.
We found that weakreflist demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.