[Python-3000] Builtin iterator type

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Fri Nov 17 11:35:34 CET 2006


Hi,

George Sakkis wrote:
> On 11/13/06, Guido van Rossum <guido at python.org> wrote:
>> Are you going to propose similar
>> changes for all standard de-facto interfaces, like sequences,
>> mappings, files etc.?
> 
> No, I won't (at least not for now ;-)). Notice however that most
> user-defined sequences, mappings, etc. usually don't start from
> scratch; they either inherit from an existing type or from an
> appropriate mixin.

I absolutely disagree. One advantage of the way Python handles protocols like
sequences, mappings and file-likes is that you do not have to implement the
entire protocol if all you want is a thing to be, say, indexable.

In most cases I've come across, I did not need to use any special base class
or mixin at all, partly because I didn't need the complete protocol anyway,
partly for performance reasons, partly because the the behaviour of the class
was so different from a list that there was no big gain in having a partial
implementation.

A superclass like UserDict etc. can be helpful, but requiring you to inherit
from it seems plain wrong in my eyes.

Stefan


More information about the Python-3000 mailing list