'If key is in table, update it. Otherwise, extend the array to make
room. This uses additive resizing not multiplicative, since the number
of keys is not likely to change frequently during a run, so do not abuse
it.
Raises an error if you try to change the type of the value stored for
that key--if you need to do this, you must delete the key first.'

def __setitem__(self, key, value):

    val_type = type(value)
    if (val_type not in self.types):
        raise TypeError(('SharedTable    does    not    support    type    ' + type(value)))
    if (val_type == str):
        value = sys.intern(value)
    if (key in self.idx):
        (idx, typ) = self.idx[key]
        if (typ != val_type):
            raise TypeError((('Cannot    change    stored    type    for    {key}    from    ' + '{v1}    to    {v2}.    You    need    to    del    the    key    first') + '    if    you    need    to    change    value    types.').format(key=key, v1=typ, v2=val_type))
        self.arrays[typ][idx] = value
    else:
        old_array = self.arrays[val_type]
        ctyp = self.types[val_type]
        new_array = RawArray(ctyp, (len(old_array) + 1))
        for i in range(len(old_array)):
            new_array[i] = old_array[i]
        new_array[(-1)] = value
        self.arrays[val_type] = new_array
        self.idx[key] = ((len(new_array) - 1), val_type)
