On Wed, Nov 20, 2002, Raymond Hettinger wrote: > > Have dictionaries support the repetition. Use the replication factor > to provide a hint as to how large the dictionary is expected to be. > > [0] * n # allocate an n-length list > {} * n # allocate an n-element dictionary > > If the a list already has k elements, the result is already n*k long; > however, for a dictionary, since the keys are unique, the result says > at n*1. Hence, the dictionary contents are unaffected by repetition. > But the n-factor is useful for eliminating all but one of the re-size > operations when growing a large dictionary, element by element. IIRC, dictionaries historically have only resized when *adding* elements, so it's common for dictionaries to resize *smaller* during an add, which would defeat the purpose. Also, dictionaries have always used exponential resize, so it's contant amortized time. I vote YAGNI -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "If you don't know what your program is supposed to do, you'd better not start writing it." --Dijkstra
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4