How do I programmatically determine if an object is a 'linked duplicate' of another? I'm trying to determine if an object is a linked duplicate in a script.
My test scene is as simple as possible, 2 cubes, one a linked duplicate of another.
The following I have tried to no avail:

bpy.data.objects[&quot;Cube.001&quot;].library (returns None)
bpy.data.objects[&quot;Cube.001&quot;].original (returns &quot;Cube.001&quot;)
bpy.data.objects[&quot;Cube.001&quot;].is_property_set(&quot;linked&quot;) (fails to run)

I attempted to grep around in the source code to find a solution but I, unfortunately, couldn't find anything that worked.
Object.data
Linked duplicates will have the same linked data, if there is linked data.  For an empty ob.data is None
import bpy
from collections import defaultdict

scene = bpy.context.scene

data_links = defaultdict(list)
for ob in scene.objects:
    data_links[ob.data].append(ob)
    
for k, v in data_links.items():
    print(k, v)

Sample output,  notice there are 4 objects using the mesh &quot;Cube.001&quot;
&lt;bpy_struct, Mesh(&quot;Cube.001&quot;)&gt; [bpy.data.objects['Cube'], bpy.data.objects['Cube.001'], bpy.data.objects['Cube.002'], bpy.data.objects['Cube.003']]
&lt;bpy_struct, PointLight(&quot;Lamp&quot;)&gt; [bpy.data.objects['Lamp']]
&lt;bpy_struct, Camera(&quot;Camera&quot;)&gt; [bpy.data.objects['Camera']]
None [bpy.data.objects['Empty'], bpy.data.objects['Field']]