potiuk commented on PR #33508:
URL: https://github.com/apache/airflow/pull/33508#issuecomment-1685285377

   > Personally I still like to use OrderedDict, especially for things that 
explicitly depend on the ordering, such as the executor queue. But I guess this 
is subjective.
   
   I used to think the same, but after moving to 3.7 and then 3.8, it's already 
past the Python minor version where it's been not only working like that (3.6)  
but also official (3.7). And I think it's better to use it when it **really** 
matters - especially that there are cases we potentially want to to 
specifically use OrderedDict (and ones that are highly unlikely to be 
incorporated into regular dict). 
   
   After adding 
[reversed](https://docs.python.org/3.7/library/functions.html#reversed) to a 
regular dict in 3.8 (which means we can use it now), there is still two things 
that **really** make a difference between regular and Ordered dicts that 
matters. 
   
   * Ability to re-arrange the order with move_to_end() which can move items to 
end (or beginning surprisingly) in an efficient way without reordeding the 
whole dict - which makes it better to do any kind of LRU caching.
   
   * Equality comparision - when we want to check if the two dicts have the 
same order when comparing them.
   
   ```
   >>> OrderedDict([(1,1), (2,2)]) == OrderedDict([(2,2), (1,1)])
   False
   >>> dict([(1,1), (2,2)]) == dict([(2,2), (1,1)])
   True
   ```
   
   So I guess it's better to use OrderedDict when we want to make use of one of 
those properties.
   
   I looked through the changes and does not seem either order-sensitive 
equality of re-arranging is used/intended to be used :).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to