How to make a growing unique index (IntProperty) of the objects? I would like to assign a unique Immutable index of the objects that are added in the scene.
I want this unique index to be stored in an object type property (Relative to the object)
Obviously the object can be deleted and I would like the index to always grow regardless of whether the object is deleted (keeping it stored somewhere)
So assuming you have 10 objects in the scene, they will have an index, from 1 to 10
Assuming deleting all 10 objects, I would like that by adding a new object, the index continues to grow, i.e. in this case the index should be 11, Obviously the index could be very high even if there are few objects in the scene, but it is very important that it remains so, and that it is always growing.
I suppose I should create a list that contains all the previous indexes or something similar.
This situation is making me difficult.
This is how we declare an object-type property:
I don't really know how to build a function that assigns correctly only when the len(bpy.data.objects[:]) changes, I can also think of a function called by bpy.app.handlers.depsgraph_update_post(), but I'm not sure
class ObjectProperties(bpy.types.PropertyGroup):
    obj_index = bpy.props.IntProperty()

def register():
    bpy.types.Object.obj_prop = bpy.props.PointerProperty(type=ObjectProperties)

My question is inherent in this answer , I was thinking of indexing all the objects present in the bpy.data.objects with a unique index.
I want to try replacing the &quot;Object Info&quot; node with a driver, which is driven by the object's IntProperty Like this:

An additional problem is when copying the object (Without instance)
I have done various tests, but there seems to be some problem with updating the integer value in the Driver.
Based on @batFINGER 's answer, the indexing method seems to be right for me. But I can't understand where I am wrong with the driver, when I assign sefl.scene_object_index to the driver, the driver never changes and always remains on 0 Although in this case C.object.scene_object_index is 6 (As seen in the console)

I had already noticed this problem, when I tried to make an index in my own way, I noticed that the driver was assuming wrong values
A collection of pointers
Can set up a collection on the scene with pointers to objects.
On an object set up a property to populate the collection and return the objects index in that collection.
Feel it's a little hacky to use context to get the scene within the getter method.
Example of setting up the props.
import bpy
from bpy.props import PointerProperty, CollectionProperty, IntProperty
from bpy.types import PropertyGroup, Object

class SceneObject(PropertyGroup):
    object : PointerProperty(type=Object)

def get_scene_object_index(self):
    from bpy import context
    scene = context.scene
    obs = [o.object for o in scene.scene_objects]
    for ob in set(scene.objects) - set(obs):
        o = scene.scene_objects.add()
        o.name = ob.name
        o.object = ob
        obs.append(ob)
        ob[&quot;scene_object_index&quot;] = len(obs)
    
    return self[&quot;scene_object_index&quot;]   


bpy.utils.register_class(SceneObject)

bpy.types.Scene.scene_objects = CollectionProperty(type=SceneObject)
Object.scene_object_index = IntProperty(get=get_scene_object_index)

def draw(self, context):
    layout = self.layout
    scene = context.scene
    ob = context.object
    self.layout.prop(ob, &quot;scene_object_index&quot;)
    for o in context.scene.scene_objects:
        layout.label(text=f&quot;{o.object.name}&quot;)    

bpy.types.OBJECT_PT_context_object.prepend(draw)

Added a little draw method to object props panel
Drive the pass_index
A driver using this prop can be added to the pass index of an object.  Adding a value input driver to a material node will require targeting a different object per material.
EDIT
Have edited to give each object a custom property. Needs a rethink re property name to have a unique value per scene.  It appears the driver &quot;auto updates&quot; better from the custom property rather than the read (getter) only property.
Will revisit and clean up if I have time, thinking a prop on scene with an update method.

Note at issue here is the collection property of the scene is giving the object a user. Deleting objects using operator will only unlink them from the scene, not remove them from the data.   Requires an edit to remove objects if they are only used by the collection.
If an object that is assigned to a pointer is removed from data the pointer will return None