def _pickle_context(ctx):
    shifted_ctx = cython.declare(MDFContext)
    node = cython.declare(MDFNode)
    node_state = cython.declare(NodeState)

    all_ctx_ids = [ctx.get_id()]

    # get the shift sets for all shifted contexts
    shift_sets = []
    for shifted_ctx in ctx.get_shifted_contexts():
        shift_set = shifted_ctx.get_shift_set()
        shift_sets.append((shifted_ctx.get_id(), shift_set))
        all_ctx_ids.append(shifted_ctx.get_id())

    # get the cached values for all nodes in any of the contexts we're interested in
    node_states = []
    for node in _all_nodes.itervalues():
        for ctx_id, node_state in node._states.iteritems():
            if ctx_id in all_ctx_ids:
                node_states.append((ctx_id, node, NodeStateWrapper(node_state)))

    return (ctx.__class__,
            ctx.get_id(),
            ctx.get_date(),
            node_states,
            shift_sets)
returns a picklable tuple of args to be passed to _unpickle_context
dataset/ETHPy150Open manahl/mdf/mdf/ctx_pickle.py/_pickle_context