PEP 245
Clark C. Evans
cce at clarkevans.com
Fri Apr 6 10:06:49 EDT 2001
On Fri, 6 Apr 2001, Scott Finnie wrote:
> Hmmm. A question about PEP245: how do interfaces differ from types?
I'm not part of the core team, but here is my understanding:
1) "type" is a function, i.e., type(thing) returns one
and only one result, type(myObject) is types.InstanceType
2) "instance" is a relation, i.e., isinstance(object,interface)
gives a boolean telling you if (object,interface) are a
member of this relation.
3) Types are used internally to determine how they are
treated, all instance types are treated in a similar way
where as a built-in types have a different C/Java
implementation.
4) Interfaces will be user definable, types are not.
5) To change types would be difficult (due to backward compatibility)
6) I'd like to have interfaces soon, and rather not wait
for the type system to be complete re-written.
> There are currently limitations on typing (only covers built-ins, object
> can only be of a single type) but neither of these seem justifiable
> reasons for introducing a new construct rather than extending the
> existing one?
I'm sure Guido will take this position into account when
examining the PEP.
;) Clark
More information about the Python-list
mailing list