[Python-Dev] PEP 246, redux (original) (raw)

Roeland Rengelink roeland.rengelink at chello.nl
Wed Jan 12 02:48:43 CET 2005


I'm trying to understand the relation between Guido's posts on optional static typing and PEP 245 (interfaces) and 246 (adaptation). I have a couple of questions

PEP 245 proposes to introduce a fundamental distinction between type and interface. However, 245 only introduces a syntax for interfaces, and says very little about the semantics of interfaces. (Basically only that if X implements Y then implements(X, Y) will return True). The semantics of interfaces are currently only implied by PEP 246, and by Guido's posts referring to 246.

Unfortunately PEP 246 explicitly refuses to decide that protocols are 245-style interfaces. Therefore, it is not clear to me how acceptance of 245 would impact on 246? Specifically, what would be the difference between:

x = adapt(obj, a_245_style_interface)

x = adapt(obj, a_protocol_type)

and, if there is no difference, what would the use-case of interfaces be?

Put another way: explicit interfaces and adaptation based typing seem to be about introducing rigor (dynamic, not static) to Python. Yet, PEP 245 and 246 seems to go out of their way to give interfaces and adaptation as little baggage as possible. So, where is the rigor going to come from?

On the one hand this seems very Pythonic - introduce a new feature with as little baggage as possible, and see where it evolves from there. Let the rigor flow, not from the restrictions of the language, but from the expressive power of the language.

On the other hand: why not, at least:

I would volunteer, but, for those of you who hadn't noticed yet, I don't know what I'm talking about.

Cheers,

Roeland Rengelink



More information about the Python-Dev mailing list