> On Sep 13, 2015, at 3:49 AM, Maciej Fijalkowski <fij...@gmail.com> wrote: > >> The intended semantics are that the itertools are classes (not functions >> and not generators). They are intended to be sub-classable (that is >> why they have Py_TPFLAGS_BASETYPE defined). > > Ok, so what's completely missing from the documentation is what *are* > the semantics of subclasses of those classes? Can you override any > magic methods? Can you override next (which is or isn't a magic method > depending how you look)? Etc. > > The documentation on this is completely missing and it's left guessing > with "whatever cpython happens to be doing".
The reason it is underspecified is that this avenue of development was never explored (not thought about, planned, used, tested, or documented). IIRC, the entire decision process for having Py_TPFLAGS_BASETYPE boiled down to a single question: Was there any reason to close this door and make the itertools not subclassable? For something like NoneType, there was a reason to be unsubclassable; otherwise, the default choice was to give users maximum flexibility (the itertools were intended to be a generic set of building blocks, forming what Guido termed an "iterator algebra"). As an implementor of another version of Python, you are reasonably asking the question, what is the specification for subclassing semantics? The answer is somewhat unsatisfying -- I don't know because I've never thought about it. As far as I can tell, this question has never come up in the 13 years of itertools existence and you may be the first person to have ever cared about this. Raymond _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com