here's the top of the function commented:
def iterate(self):
# this function is the guts of a class that wraps a tree root record
# indexing binary data on a blockchain. it is intended to yield the
# chunks in order when called.
# the number of bytes that have been yielded, increased every chunk
stream_output_offset = 0
# the size of all the chunks: the sum of the sizes of each child node
total_size = len(self)
# for debugging: tracks nodes that should only be visited
once, to check this
visited = set()
# a stack to perform a depth-first enumeration of the tree
# atm, the child offset is not tracked as inner nodes are traversed.
# instead, the global offset is tracked, and children are enumerated
# again when backtracking, under the idea that total time is still
# O(log n)
# index stream offset index offset region size
indices = [(self.tail, 0, 0, total_size)]
I think I might like to think about dependency and information and
control flow relations between general areas of the function now.