a clean way to define dictionary
mis6 at pitt.edu
Fri Jun 20 19:37:26 CEST 2003
Alexander Schmolck <a.schmolck at gmx.net> wrote in message news:<yfs7k7g7q64.fsf at black132.ex.ac.uk>...
> mis6 at pitt.edu (Michele Simionato) writes:
> > Sorry for the typo, of course I meant __setitem__/__getitem__.
> > I am saying that a workaround for the change of the constructor signature
> > is to subclass dict and to override the constructor. There is
> > not a big penalty and you seems to agree (your last sentence).
> > Overriding __getitem__ gives a big penalty, that's true, but this has
> > nothing to do with the change of the constructor in Python 2.3, right ?
> > I do not understand where the source of the confusion is (if any).
> OK, I see now what you mean. I don't agree the penalty for overriding
> __getitem__ "has nothing to dow ith change of the constructor" in the context
> of deciding whether it would be more desirable to 'enhance' dicts with a new
> 'default' option or the syntactic sugar behavior.
Still I don't understand your point. Anyway, the access
time to DefaultDict objects with Python 2.3b1 is ~40% *faster*
than with Python 2.2.0.
More information about the Python-list