Package horizons :: Package util :: Package python :: Module weaklist :: Class WeakList
[hide private]
[frames] | no frames]

Class WeakList

source code


A Weak_list can store objects but without keeping them
alive with references couting incrementation.

When objects are deleted or garbage_collected, they disappear from
the list.

! WARNING: due to the *magic* deletion of item, some method here
are not guaranteed to give the right result or even to work properly.

This class is NOT thread safe and NOT GC safe.

You can have problem with:

- extend can add broken weakref in the list
- sort can crash
- __iter__, __str__, __repr__ and __reversed can return some None
- all the rich comparison method
- count can return wrong values or outdated
- index can return too high values or forget to raise exceptions
- __get_item__ and __set_item__ are useless

Be also careful that your work with weakref, so some usual
tips don't work:

>>> weak = weaklist.WeakList(weakable_class())
>>> len(a)
0

Instance Methods [hide private]
 
__init__(self, items=None) source code
 
__str__(self) source code
 
__repr__(self) source code
 
__new_weakref(self, item)
Create a weakref with the good callback
source code
 
__iter_over_weakref(self, iterable)
For a given iterable, return an iterable generator over all weakref
source code
 
__remove_ref(self, ref)
When an object from the list is destroy, this method is call to remove it from list
source code
 
extend(self, iterable) source code
 
append(self, obj) source code
 
remove(self, obj) source code
 
count(self, value) source code
 
index(self, value, *args) source code
 
pop(self, index=-1) source code
 
sort(self, cmp=None, key=None, reverse=False) source code
 
insert(self, index, obj) source code
 
__getitem__(self, index) source code
 
__setitem__(self, index, value) source code
 
__iter__(self) source code
 
__contains__(self, item) source code
 
__getslice__(self, i, j) source code
 
__setslice__(self, i, j, iterable) source code
 
__reversed__(self) source code
 
__iadd__(self, other) source code
 
__add__(self, other) source code
 
__eq__(self, other) source code
 
__ge__(self, other) source code
 
__le__(self, other) source code
 
__gt__(self, other) source code
 
__ne__(self, other) source code
 
__lt__(self, other) source code