Re: Large Dictionaries



Roy Smith:
I am befuddled as to why
people thought creating a dict by keyword would be a useful thing to
do, but left out (and, indeed, eliminated the chance to add the syntax
later) the obviously useful ability to hint at the size.

Adding the keyword syntax doesn't require much memory to a Python
programmer because it's the same syntax used elsewhere. While adding
another different method to dicts increases their API. Python is
usually designed to have smaller APIs, to help programmers remember
most things.

I agree that a reserve method to Python dicts/sets can be a little
useful, but Python programmers are usually more concerned about doing
things in a short programmer time and short code space, than telling
the computer how to do such things in the faster way (C++ is more for
speed so the reserve of the STL hashes can be more useful).

Bye,
bearophile

.



Relevant Pages

  • extracting order of class attribute setting = statement execution or keyword assignments?
    ... i want to have the order of setting items in intrinsic dicts (keyword ... matches the source-text sequences. ... [ordered dict is a dict that keep somewhere order of key ... i want to use python instead of XML et al ...
    (comp.lang.python)
  • replacing builtins (WAS: Regular Expressions: large amount of ors)
    ... > Python allows to subclass builtin classes but the Python Interpreter ... > As an example keyword arguments are inserted in a dict but I would ...
    (comp.lang.python)
  • Re: Python or PHP?
    ... If it's one of the things for which Python ... every language here and there more ways to do something. ... you make Perl more complicated than it is:-D. ... Not the programmer. ...
    (comp.lang.python)
  • Can you introduce some book about python?
    ... appending key-value pairs to a dict (Peter ... Is Python suitable for a huge, ... >> to the list on each loop... ...
    (comp.lang.python)
  • Re: Thoughts about Python
    ... > learning Python. ... Since several people have already mentioned that the syntax ... there is very little in any programming language that is ... filed in the dict under the old rather than the new hash code. ...
    (comp.lang.python)