Unique and invariable ID (within the session) for an object? I have tried print(context.active_object.name_full), but that seems to be just the object name that I see in the Outliner. If I change the name in the Outliner, then name_full changes, too.
Is there any unique and invariable ID to identify an object at least within the session? That is, the unique ID should not be changed even if the user changes the object's name. The ID does not have to be same if the user opens the file again next time.
Use a pointer property
Can set up a pointer to any blender ID type objects, in this case bpy.types.Object instances of which can be found in bpy.data.objects collection.
Assign the property to class
import bpy
from bpy.types import Object, Scene
from bpy.props import PointerProperty


Scene.target_obj = PointerProperty(type=Object)

Test.
&gt;&gt;&gt; C.object
bpy.data.objects['Cube']

&gt;&gt;&gt; bpy.ops.object.duplicate()
{'FINISHED'}

&gt;&gt;&gt; C.object
bpy.data.objects['Cube.001']

&gt;&gt;&gt; C.scene.target_obj = C.object
&gt;&gt;&gt; C.object.name = &quot;Foo&quot;
&gt;&gt;&gt; C.scene.target_obj
bpy.data.objects['Foo']