hash codes the first action that hash function performs is to take an arbitrary key in our map and compute an integer that is called the hash code for kthis integer need not be in the range [ ]and may even be negative we desire that the set of hash codes assigned to our keys should avoid collisions as much as possible for if the hash codes of our keys cause collisionsthen there is no hope for our compression function to avoid them in this subsectionwe begin by discussing the theory of hash codes following thatwe discuss practical implementations of hash codes in python treating the bit representation as an integer to beginwe note thatfor any data type that is represented using at most as many bits as our integer hash codeswe can simply take as hash code for an integer interpretation of its bits for examplethe hash code for key could simply be the hash code for floating-point number such as could be based upon an interpretation of the bits of the floating-point representation as an integer for type whose bit representation is longer than desired hash codethe above scheme is not immediately applicable for examplepython relies on -bit hash codes if floating-point number uses -bit representationits bits cannot be viewed directly as hash code one possibility is to use only the high-order bits (or the low-order bitsthis hash codeof courseignores half of the information present in the original keyand if many of the keys in our map only differ in these bitsthen they will collide using this simple hash code better approach is to combine in some way the high-order and low-order portions of -bit key to form -bit hash codewhich takes all the original bits into consideration simple implementation is to add the two components as bit numbers (ignoring overflow)or to take the exclusive-or of the two components these approaches of combining components can be extended to any object whose binary representation can be viewed as an -tuple ( xn- of -bit integersfor exampleby forming hash code for as - = xi or as *xn- where the symbol represents the bitwise exclusive-or operation (which is in pythonpolynomial hash codes the summation and exclusive-or hash codesdescribed aboveare not good choices for character strings or other variable-length objects that can be viewed as tuples of the form ( xn- )where the order of the xi ' is significant for exampleconsider -bit hash code for character string that sums the unicode values of the characters in this hash code unfortunately produces lots of unwanted