How do find all instances of a mesh via Python? All answers I've seen here before say to check whether an object has multiple users to know if it's instanced or not, but what if you have multiple objects with multiple instances of each?
How do you sort through them in Python?
(What I really want to figure out is how to perform operations in script which are normally forbidden on instances in Blender, but first steps first.)
PS. Not talking about collections here, but objects/meshes!
For all meshes and their instances, you can loop over the mesh objects and collect objects that correspond to the same mesh using a dictionary:
import bpy
from collections import defaultdict

result = defaultdict(list)

for obj in [o for o in bpy.data.objects if o.type == 'MESH']:
    result[obj.data].append(obj)
    
for mesh, objects in result.items():
    print( &quot;Mesh &quot; + mesh.name + &quot; has &quot; + &quot;, &quot;.join(o.name for o in objects) + &quot; object(s) for instance(s)&quot;)

Or, to find instances of one mesh:
import bpy

obj = bpy.data.objects['Cube']

instances = [o for o in bpy.data.objects if o.data == obj.data]

print(instances)