[Python-Dev] PySequence_Concat for dicts

Jared Flatow jflatow at northwestern.edu
Sat Jan 12 00:01:10 CET 2008


Hi all,

I am fairly new to the Python community so please forgive me (and  
correct me) if I am going about this wrong.

I think it would be convenient and pythonic if dict objects  
implemented the PySequence_Concat method. I see there was once a  
short-lived discussion about this here:

http://mail.python.org/pipermail/patches/2004-March/014323.html

I have also been following the discussion about contributing to  
Python. It seems to me that this would be a fairly easy feature to  
implement (perhaps naively?), and I would be glad to try writing a  
patch for this if there is at least some chance of it making it into  
one of the branches. Can someone please advise me on what the correct  
order for going about this would be? Do I need to first write a PEP  
justifying why I think it would be an improvement? Which version of  
Python (if any), should a patch be targeted at?

Otherwise, is there a good reason dicts do not already implement this  
method? I somewhat understand the complaint about commutativity, but  
as mentioned in the previous discussion, list concatenation is not  
commutative either. Seeing as update is the only builtin method for  
concatenation of dicts in the first place, it doesn't seem all that  
confusing that 'summing' two dicts should conveniently return a new  
instance that is the (only form of) concatenation of the two dicts.

regards,
jared


More information about the Python-Dev mailing list