Python 2.2b1 dicts, iteration, and subclassing
Martin von Loewis
loewis at informatik.hu-berlin.de
Sun Dec 2 15:34:23 CET 2001
Alexis Layton <alexis.layton at post.harvard.edu> writes:
> The question for all you Pythonistas out there is, should it? To
> what extent should the built-in behavior of objects like
> dictionaries be affected by subclassing?
I would say that the documentation decides; if it is undocumented, the
implementation may do whatever it feels like.
In the specific case, it sounds reasonable that dict_repr uses the
iteration of the dictionary (which one? probably
iteritems). Currently, it uses the same back-end that the built-in
dictionary iteration uses. That, of course, is because nobody thought
of this application.
If you are really interested in this, I recommend you work out a patch
to dictobject.c, and to the documentation. If you are less interested,
just file an SF bug report. In either case, it is, unfortunately,
unlikely that something will change for 2.2.
More information about the Python-list