Source code for example_code.linked_list

import sys





[docs]class LinkIterator: def __init__(self, link): self.here = link def __iter__(self): return self def __next__(self): if self.here: next = self.here self.here = self.here.next return next.value else: raise StopIteration
[docs]def byte_size(n): """Print the size in bytes of lists up to length n.""" data = [] for i in range(n): a = len(data) b = sys.getsizeof(data) print(f"Length:{a}; Size in bytes:{b}") data.append(i)