huffman.py
def make_freq_table(stream):
    """
    Given an input stream, will construct a frequency table
    (i.e. mapping of each byte to the number of times it occurs in the stream).

    The frequency table is actually a counter.
    """

    freqs = Counter()
    buffer = bytearray(512)
    while True:
        count = stream.readinto(buffer)
        freqs.update(buffer[:count])
        if count < len(buffer): # end of stream
            break
    return freqs

    Given an input stream, will construct a frequency table
    (i.e. mapping of each byte to the number of times it occurs in the stream).

    The frequency table is actually a counter.
    
Given an input stream, will construct a frequency table
.

The frequency table is actually a counter.
Given an input stream will construct a frequency table . The frequency table is actually a counter .
def make_freq_table(stream):
    freqs = Counter()
    buffer = bytearray(512)
    while True:
        count = stream.readinto(buffer)
        freqs.update(buffer[:count])
        if count < len(buffer): 
            break
    return freqs
def make_freq_table ( stream ) : freqs = Counter ( ) buffer = bytearray ( 512 ) while True : count = stream . readinto ( buffer ) freqs . update ( buffer [ : count ] ) if count < len ( buffer ) : break return freqs
Given an input stream, will construct a frequency table
(i.e.
Given an input stream will construct a frequency table ( i . e .
"""
    Given an input stream, will construct a frequency table
    (i.e. mapping of each byte to the number of times it occurs in the stream).

    The frequency table is actually a counter.
    """ # end of stream
stream