Going through the elements of xarray one-by-one has at best linear (O(n)) complexity. Internally xarray is an RB-tree, a balanced binary search tree. Search inside such a data structure has complexity O(log n). In a long run it is important to use the most fitting interface for the purpose.
https://github.com/yaoxinjing/simpleDeviceDriver/blob/575ebb004b1771e8767032e12f068a7123ba28c3/device_file.c#L130-L138
Going through the elements of xarray one-by-one has at best linear (O(n)) complexity. Internally xarray is an RB-tree, a balanced binary search tree. Search inside such a data structure has complexity O(log n). In a long run it is important to use the most fitting interface for the purpose.