On Friday, December 2, 2011 5:53:47 PM UTC+8, Hrvoje Niksic wrote: > Chris Angelico <ros...@gmail.com> writes: > > >> The hash can grow with (k,v) pairs accumulated in the run time. > >> An auto memory management mechanism is required for a hash of a non-fixed > >> size of (k,v) pairs. > > > > That's a hash table > > In many contexts "hash table" is shortened to "hash" when there is no > ambiguity. This is especially popular among Perl programmers where the > equivalent of dict is called a hash. > > > Although strictly speaking, isn't that "Python dicts are implemented > > as hash tables in CPython"? Or is the hashtable implementation > > mandated? > > It's pretty much mandated because of the __hash__ protocol.
I agree with you. When a hash is inserted with (k,v1) and then (k,v2) such that v1!=v2, there are several possibilities to handle this situation in programming: 1. v2 just replaces v1 with or without a message 2. the programmer can delete the (k,v1) entry and then insert a (k, (v1,v2)) entry. 3. the programmer initializes a tuple of (v1,v2), and then delete the (k,v1) entry to be replaced by a (k,(v1,v2)) entry. Hashes of hashes are really powerful in Python to be used to build a relational DB of thousands of thousands of objects or records in a piece of cake. A similar hash library in C is to be used everywhere is not difficult at all. -- http://mail.python.org/mailman/listinfo/python-list