I am a novice when it comes to coding. I’ve been reading a lot of the help threads on this forum and on stack exchange and the Blender discord and from the various answers I’ve seen at least 3 different ways to get a list of the currently selected objects. I was wondering why one would want to check view_layer.objects or context.scene.objects when context.selected_objects exists and seems like it would be the most performant (least amount of iterating over the scene).
foo = context.selected_objects
bar = []
for o in bpy.context.view_layer.objects.selected:
bar.append(o)
baz = [o for o in context.scene.objects if o.select_get()]