[Python-Dev] ABC issues
Guido van Rossum
guido at python.org
Tue May 27 20:42:57 CEST 2008
On Tue, May 27, 2008 at 10:44 AM, Raymond Hettinger <python at rcn.com> wrote:
>>>> * The 2.6-backported Mapping ABC has the 3.0 dict API,
>>>> that is, it uses keys() that returns a view etc.
>>>
>>> Curious to hear what Guido thinks about this one.
>>> A nice use of the Mapping ABC is to be able to
>>> get 3.0 behaviors. I thought that was the whole
>>> point of all these backports. If the ABC gets altered,
>>> then it just makes the 2-to-3 conversion harder.
>>
>> It's wrong if the ABC doesn't describe the behavior of actual
>> implementations; that is its primary purpose, the mixin class is a
>> nice side benefit.
>
> ISTM, the one purpose of backporting is to make 2.6 closer to 3.0. Altering
> the API will just make them further apart.
Well, the ABCs have two sides -- they describe the API and they
provide a mix-in. I feel strongly that the primary function of ABCs is
to describe the API (in fact many ABCs do only that, e.g. look at
Sized and Container). I want isinstance({}, collections.Mapping) to be
true.
If you want to use the 3.0 mixins in 2.6, perhaps an alternate set of
APIs could be imported from the future? E.g. from future_collections
import Mapping. IIRC a similar mechanism was proposed for some
built-in functions, even though I see no traces of an implementation
yet.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list