This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients christian.heimes, rhettinger
Date 2014-02-18.17:33:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1392744795.57.0.649500024154.issue20674@psf.upfronthosting.co.za>
In-reply-to
Content
The hash function comments in Objects/dictobject.c no longer match the implementation:

"""
/*                                                                                                                                
Major subtleties ahead:  Most hash schemes depend on having a "good" hash                                                         
function, in the sense of simulating randomness.  Python doesn't:  its most                                                       
important hash functions (for strings and ints) are very regular in common                                                        
cases:                                                                                                                            
                                                                                                                                  
  >>> map(hash, (0, 1, 2, 3))                                                                                                     
  [0, 1, 2, 3]                                                                                                                    
  >>> map(hash, ("namea", "nameb", "namec", "named"))                                                                             
  [-1658398457, -1658398460, -1658398459, -1658398462]                                                                            
  >>>                                                                                                                             
                                                                                                                                  
This isn't necessarily bad!  To the contrary, in a table of size 2**i, taking                                                     
the low-order i bits as the initial table index is extremely fast, and there                                                      
are no collisions at all for dicts indexed by a contiguous range of ints.                                                         
The same is approximately true when keys are "consecutive" strings.  So this                                                      
gives better-than-random behavior in common cases, and that's very desirable. 
"""
History
Date User Action Args
2014-02-18 17:33:15rhettingersetrecipients: + rhettinger, christian.heimes
2014-02-18 17:33:15rhettingersetmessageid: <1392744795.57.0.649500024154.issue20674@psf.upfronthosting.co.za>
2014-02-18 17:33:15rhettingerlinkissue20674 messages
2014-02-18 17:33:14rhettingercreate