A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2002-November/030282.html below:

[Python-Dev] Dictionary Foolishness?

[Python-Dev] Dictionary Foolishness? [Python-Dev] Dictionary Foolishness?Raymond Hettinger Raymond Hettinger" <python@rcn.com
Wed, 20 Nov 2002 15:12:56 -0500
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.

If k > n, then the hint is disregarded since the
number of elements already exceeds the hint.


Raymond Hettinger




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