| |
- tuple(object)
-
- WeakTuple
class WeakTuple(tuple) |
|
tuple sub-class holding weakrefs to items
The weak reference tuple is intended to allow you
to store references to a list of objects without
needing to manage weak references directly.
For the most part, the WeakTuple operates just
like a tuple object, in that it allows for all
of the standard tuple operations. The difference
is that the WeakTuple class only stores weak
references to its items. As a result, adding
an object to the tuple does not necessarily mean
that it will still be there later on during
execution (if the referent has been garbage
collected).
Because WeakTuple's are static (their membership
doesn't change), they will raise ReferenceError
when a sub-item is missing rather than skipping
missing items as does the WeakList. This can
occur for basically _any_ use of the tuple. |
|
- Method resolution order:
- WeakTuple
- tuple
- object
Methods defined here:
- __add__(self, other)
- Return a new path with other as tail
- __contains__(self, item)
- Return boolean indicating whether the item is in the tuple
- __eq__(self, sequence)
- Compare the tuple to another (==)
- __ge__(self, sequence)
- Compare the tuple to another (>=)
- __getitem__(self, index)
- Get the item at the given index
- __getslice__(self, start, stop)
- Get the items in the range start to stop
- __gt__(self, sequence)
- Compare the tuple to another (>)
- __init__(self, sequence=())
- Initialize the tuple
The WeakTuple will store weak references to objects
within the sequence.
- __iter__(self)
- Iterate over the tuple, yielding strong references
- __le__(self, sequence)
- Compare the tuple to another (<=)
- __lt__(self, sequence)
- Compare the tuple to another (<)
- __ne__(self, sequence)
- Compare the tuple to another (!=)
- __repr__(self)
- Return a code-like representation of the weak tuple
- count(self, item)
- Return integer count of instances of item in tuple
- index(self, item)
- Return integer index of item in tuple
- unwrap(self, item)
- Unwrap an individual item
This is a fairly trivial operation at the moment,
it merely calls the item with no arguments and
returns the result.
- valid(self)
- Explicit validity check for the tuple
Checks whether all references can be resolved,
basically just sees whether calling list(self)
raises a ReferenceError
- wrap(self, item)
- Wrap an individual item in a weak-reference
If the item is already a weak reference, we store
a reference to the original item. We use approximately
the same weak reference callback mechanism as the
standard weakref.WeakKeyDictionary object.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
Methods inherited from tuple:
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __getnewargs__(...)
- __hash__(...)
- x.__hash__() <==> hash(x)
- __len__(...)
- x.__len__() <==> len(x)
- __mul__(...)
- x.__mul__(n) <==> x*n
- __rmul__(...)
- x.__rmul__(n) <==> n*x
- __sizeof__(...)
- T.__sizeof__() -- size of T in memory, in bytes
Data and other attributes inherited from tuple:
- __new__ = <built-in method __new__ of type object at 0x820c40>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
| |