[Python-Dev] Shared ABCs for the IO implementation (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Wed Feb 25 22:03:22 CET 2009


Guido van Rossum <guido python.org> writes:

Without a shared ABC you'd defeat the whole point of having ABCs. However, importing ABCs (which are defined in Python) from C code (especially such fundamental C code as the I/O library) is really subtle and best avoided. In io.py I solved this by having a Python class inherit from both the ABC (RawIOBase) and the implementation (fileio.FileIO).

My plan (let's call it "the Operation") is to define the ABCs in Python by deriving the C concrete base classes (that is, have io.XXXIOBase derive _io.XXXIOBase). This way, by inheriting io.XXXIOBase, user code will benefit both from ABC inheritance and fast C concrete implementations.

In turn, the concrete implementations in _pyio (the Python version) would register() those ABCs. The reason I think the Python implementations shouldn't be involved in the default inheritance tree is that we don't want user classes to inherit a del method.

All this is assuming I haven't made any logic error. Otherwise, I'll have to launch "the new Operation".

Regards

Antoine.



More information about the Python-Dev mailing list