LSEG Workspace may return repeated instrument records when results are combined from multiple market-data sources. Given a list of dictionary objects and the name of a field that uniquely identifies an object, return the unique objects in their original order, keeping only the first object for each identifier.
Implement unique_objects(objects, key), where objects is a list of dictionaries and key is a string. Every dictionary contains the specified key, and its value is hashable. Return a new list containing the first dictionary encountered for each distinct key value. Do not modify the input list.
Objects with different values in non-key fields are still duplicates when their values for key match. The returned dictionaries should be the original objects, not copies.
def unique_objects(objects, key):