[Python-Dev] Shared ABCs for the IO implementation

Guido van Rossum guido at python.org
Wed Feb 25 22:14:19 CET 2009


On Wed, Feb 25, 2009 at 1:03 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Guido van Rossum <guido <at> 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.

However that's hardly an ABC. You need to provide a path for someone
who wants to implement the ABC without inheriting your implementation.

> 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".

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list