def add_object(doc: Doc, new_o, immut=True) -> tuple:
    """Add new object at the end of current index."""
    ver = len(doc.index)
    num = len(doc.index[-1])
    new_i = {'o_num': num, 'o_gen': 0, 'o_ver': 0, 'doc_ver': ver-1}
    if immut:
        new_doc = copy_doc(doc, revision='SAME')
    else:
        new_doc = doc
    new_doc.index[-1].append(None)
    new_doc.index[-1][num] = new_i
    new_doc.cache.append(None)
    new_doc.cache[num] = new_o
    return new_doc, complex(0, num)
Add new object at the end of current index.
pdfsyntax/docstruct.py