intersection, union, difference, symmetric difference for dictionaries

mauro mauro at gmail.com
Tue Feb 25 23:02:01 CET 2014


> 
> {'A': 1} | {'A': 2}
>
> I would propose at least four:
> 
>   {'A': 1}   # choose the LHS 
>   {'A': 2}   # choose the RHS 
>   {'A': (1,2)} # a resulting pair of both 
>   set(['A']) # you did set-ops, so you get a set

The implementation should define if LHS or RHS and user should change the 
order of operands depending on what he wants. 

Your example (as well as a many questions in stackoverflow.com) shows 
that there is some need for these operations, that implemented in C in 
python library will be by far more CPU and memory efficient than 
implemented as you did. 



More information about the Python-list mailing list