def envelopes(doc: Doc):
    """Map objects nums belonging to objects streams."""
    res = {}
    current = doc.index[-1]
    for i, x in enumerate(current):
        env_num = x.get('env_num')
        if env_num:
            if env_num not in res:
                res[env_num] = []
            res[env_num].append(i)
    return res
Map objects nums belonging to objects streams.
pdfsyntax/docstruct.py