If I understand the way it works, accessing a property by string (data["propname"] = 0
) requires the system to search for it. Iterating over all of the properties in data
, comparing the id-string until the correct one is found. But what about when we are already iterating over every property?
for key in a.keys():
a[key] = b[key]
This type of situation seems like it would be very inefficient. Especially if every access requires a search. Even if some type of hashing is automatically kicking in, it seems pretty wasteful. Is it possible to do this in a way that makes more sense? Some type of property iterator? Or any type of index or reference to the property that relates to the next one in the same structure?
If not, would it be possible to build any type of lookup table or helper utility for a situation where you need to iterate the same set of properties for many objects?
b
does it have same keys asa
... is it meant to be the other way aroundb[key] = a[key]
?wonder if using the key value pairs ofitems()
iterator, egfor key, value in a.items():
might be of use $\endgroup$a
andb
were meant to be identical objects. Yeah, you're right. Using values instead of keys would help a little. What I'm hoping for is some way to iterate properties without using string searches for each access. $\endgroup$