in ,

bpo-36144: Dictionary Union (PEP 584) by brandtbucher · Pull Request # 12088 · python / cpython, Hacker News

bpo-36144: Dictionary Union (PEP 584) by brandtbucher · Pull Request # 12088 · python / cpython, Hacker News
        

      

                          

         

       

      

                 

          

  

      

                      

    

      

 `d1   d2` is semantically identical to` d3=d1.copy (); d3.update (d2); d3`, and `d1 ​​=d2` is semantically identical to` d1.update (d2) `.  Isn't that sweet? 

    

        

      

      

                 

          

  

      

                      

    

      

 It feels so weird to sum dicts like this ... cool. 

    

        

      

      

                 

          

  

      

                      

    

      

 This gets the collections tests passing again. 

    

        

      

      

                 

          

  

      

                      

    

      

 This adds one test with 5 new assertions. 

    

        

      

      

                 

          

  

      

                      

    

      

 In case this gets pulled. Very cool! 

    

        

      

      

                 

          

  

      

                      

    

        

      

  

           

         

       

      

                 

          

  

      

                      

    

      

 This whole patch adds 3 new objects with docstrings: dict .__ add__, dict .__ radd__, dict .__ iadd__. On some builds, this puts us over the threshold, so bump the count! 

    

        

      

      

                 

          

  

      

  

          @blurb-it

                      

        

      

  

                        @blurb-it          

  

      

                 

          

  

      

                      

    

      

 Replaces two places where a failed PyDict_Update call returns NotImplemented instead of raising the error. 

    

        

      

  

                 

         

       

      

                 

          

  

      

                      

    

       This brings this reference implementation in line with PEP ‘s spec. Separately, allows RHS of =to be any valid arg to dict.update.     

        

      

      

                 

             

      

                      

    

      

 These are implemented as they are currently laid out in PEP .      

        

      

      

                 

          

  

      

                      

    

      

 This should get tests passing again. 

    

        

      

      

                 

          

  

      

                      

    

      

And … we’re officially implemented!     

        

      

      

                 

          

  

      

  

          @blurb-it

                      

        

      

      

                 

          

  

      

                      

    

        

      

  

     

                 

             

  

brandtbucher )           changed the title bpo – 69108: Dictionary addition.

(Mar 2,)   

  

               

       

      

                 

             

      

                      

    

      

 This fixes issues where iteration errors could be swallowed, and also stops a possible reference leak. 

    

        

      

      

                 

             

      

                      

    

      

 This also implements the complex keys / __ iter__ dance that update uses, as an example of compatibility with dict.update. 

    

        

      

      

                 

             

      

                      

    

      

 dict .__ iadd__ can take any mapping (i.e., a list). 

    

                      

                 

             

      

                      

    

      

 This is pretty much copied-and-pasted from UserDict, but it's better than what we had before. They may need some tweaking. 

    

        

             

                 

             

      

                      

    

      

 This was requested by Steven for comparison purposes. The final implementation will only keep one! 

    

        

                                              

  

      

                 

          

  

      

                      

        

      

  

                                                                                               

         

       

      

                 

          

  

      

                      

        

      

      

                 

          

  

      

                      

        

      

  

                                               

              

     

      

      

  

gvanrossum          merged commit (eb8ac)     into                      (python) : (master            

Feb , @blurb-it@brandtbucher       

        9 checks passed       

      

                 

                                                                             

                             

                  Azure Pipelines PR                                  # succeeded               

                

Details             

            

                             

                  bedevere / issue-number                                  Issue number 58095 found               

                

Details             

            

                             

                  bedevere / news                                  News entry found in Misc / NEWS.d               

            

            

                             

                  continuous-integration / travis-ci / pr                                  The Travis CI build passed               

                

Details             

        

      

  

                      

            (Read More)

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

The PlayStation 5 Controller Could Invade Our Privacy in Alarming New Ways, Crypto Coins News

The PlayStation 5 Controller Could Invade Our Privacy in Alarming New Ways, Crypto Coins News

Inside Waymo's Hiring Binge, Hacker News

Inside Waymo's Hiring Binge, Hacker News