def update_object(doc: Doc, num: int, new_o, immut=True) -> Doc:
    """Update object in the current revision."""
    ver = len(doc.index)
    old_i = doc.index[-1][num]
    new_i = {
        'o_num': num,
        'o_gen': old_i['o_gen'],
        'o_ver': old_i['o_ver']+1,
        'doc_ver': ver-1,
    }
    if new_o is None:
        new_i['DELETED'] = True
    if immut:
        new_doc = copy_doc(doc, revision='SAME')
    else:
        new_doc = doc
    new_doc.index[-1][num] = new_i
    new_doc.cache[num] = new_o
    return new_doc
Update object in the current revision.
pdfsyntax/docstruct.py