nspyre.data.streaming.list

Module Contents

Classes

StreamingList

List-like object that can be streamed efficiently through the DataServer.

class nspyre.data.streaming.list.StreamingList(iterable=None)

List-like object that can be streamed efficiently through the DataServer. StreamingList is meant to act as a drop-in replacement for a python list. When this object is pushed to the data server using a call to push(), instead of sending the whole contents of StreamingList, only the differences since the last push() are sent. This allows for much higher data throughput for larger data sets.

Although StreamingList is typically able to automatically calculate the differences since the last push(), there is one situation where this is not possible: if a mutable object that is contained somewhere inside the StreamingList is modified, it cannot be detected. In this situation, the StreamingList must be manually notified that one of its items has been updated, e.g.:

import numpy as np
from nspyre import DataSource
from nspyre import StreamingList

with DataSource('my_dataset') as src:
    sl = StreamingList()
    a = np.array([1, 2, 3])
    b = np.array([4, 5, 6])
    c = np.array([7, 8, 9])

    # these StreamingList calls will automatically calculate diffs
    sl.append(a)
    sl.append(b)
    sl.append(c)

    src.push(sl)

    # here we are modifying a mutable object inside of the StreamingList,
    # which it cannot detect
    a[1] = 10

    # we can manually tell the StreamingList that its object 'a' was modified
    sl.updated_item(0)

    src.push(sl)
Parameters:

iterable – iterable object to initialize the contents of the list with, e.g. sl = StreamingList([1, 2, 3]).

updated_item(idx)

The item at the given index was modified, and, therefore, its cached value is no longer valid and must be updated.

Parameters:

idx – index that was modified

insert(idx, val, register_diff=True)

See docs for Python list.

remove(val)

See docs for Python list.

pop(idx)

See docs for Python list.

append(val)

See docs for Python list.

extend(val)

See docs for Python list.

clear()

See docs for Python list.

sort(*args, **kwargs)

See docs for Python list.

reverse()

See docs for Python list.

copy()

See docs for Python list.