I'm using a dict to ensure that I have only one copy of a Path in my system:
for obj in obj_list:
obj_dict[obj.fullname]=obj
Is there some more efficient way to do this that I'm missing?
I'm using a dict to ensure that I have only one copy of a Path in my system:
for obj in obj_list:
obj_dict[obj.fullname]=obj
Is there some more efficient way to do this that I'm missing?
Not really. This method will be slower than a linear search for smaller data sets, but will be much faster for larger data sets as testing for a duplicate entry is a hash table lookup.
The time complexity of your code is amortized O(n) (the best you can hope to achieve when you have to process every item in a data set), while doing a linear search is O(n2).
Try obj in obj_list
like this 'a' in x
https://www.tutorialspoint.com/python/membership_operators_example.htm
look at create-a-dictionary-with-list-comprehension-in-python
List comprehension is much faster - I assume this is meant by efficency.