An immutable sequence that provides the ability to lazily access objects. In truth, this sequence simply wraps a list of callables which are then indexed and invoked. However, if the callable represents a function that lazily access memory, then this list simply implements a lazy list paradigm.
When slicing, another LazyList is returned, containing the subset of callables.
callables (list of callable) – A list of callable objects that will be invoked if directly indexed.
Generate an efficient copy of this LazyList - copying the underlying callables will be lazy and shallow (each callable will not be called nor copied) but they will reside within in a new list.
type(self)– A copy of this LazyList.
count(value) → integer – return number of occurrences of value¶
index(value[, start[, stop]]) → integer – return first index of value.¶
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
Create a lazy list from a callable that expects a single parameter, the index into an underlying sequence. This allows for simply creating a LazyList from a callable that likely wraps another list in a closure.
f (callable) – Callable expecting a single integer parameter, index. This is an index into (presumably) an underlying sequence.
n_elements (int) – The number of elements in the underlying sequence.
lazy (LazyList) – A LazyList where each element returns the underlying indexable object wrapped by
Create a lazy list from an existing iterable (think Python list) and optionally a callable that expects a single parameter which will be applied to each element of the list. This allows for simply creating a LazyList from an existing list and if no callable is provided the identity function is assumed.
iterable (collections.Iterable) – An iterable object such as a list.
f (callable, optional) – Callable expecting a single parameter.
lazy (LazyList) – A LazyList where each element returns each item of the provided iterable, optionally with f applied to it.
Create a new LazyList where the passed callable
fwraps each element.
fshould take a single parameter,
x, that is the result of the underlying callable - it must also return a value. Note that mapping is lazy and thus calling this function should return immediately.
fmay be a list of callable, one per entry in the underlying list, with the same specification as above.
f (callable or iterable of callable) – Callable to wrap each element with. If an iterable of callables (think list) is passed then it must by the same length as this LazyList.
lazy (LazyList) – A new LazyList where each element is wrapped by (each)
Repeat each item of the underlying LazyList
ntimes. Therefore, if a list currently has
Ditems, the returned list will contain
D * nitems and will return immediately (method is lazy).
n (int) – The number of times to repeat each item.
>>> from menpo.base import LazyList >>> ll = LazyList.init_from_list([0, 1]) >>> repeated_ll = ll.repeat(2) # Returns immediately >>> items = list(repeated_ll) # [0, 0, 1, 1]