[Python-3000] What's the point of annotations?

Collin Winter collinw at gmail.com
Wed Jan 3 18:06:06 CET 2007


On 1/2/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 05:48 PM 1/2/2007 -0600, Collin Winter wrote:
> >Is whatever savings you see there worth changing the language for? Is
> >function overloading really that important and that common?
>
> Ah, but now you're making a different argument.  Your original statement
> was that "we're getting along without annotations quite nicely"; my
> response was merely to refute that point.  There do indeed exist use cases
> that are better off with annotation than without.

The argument I was trying (and perhaps failing) to make is that it
seems like the language is being changed to make life easier for some
pretty obscure and relatively rare use-cases, even if those cases are
taken together.

(Rearranging a bit)
> Now, if you want to pick at each and every one of these use cases and
> assert that the one use case, *by itself*, doesn't justify the feature,
> well, you may be right.  But as with decorators, that doesn't necessarily
> mean the feature itself is wrong!  Decorators are an excellent example of a
> feature that meets many use cases, few if any of which would be sufficient
> in themselves to justify a language change.

> For example, interfacing to at least Java and Objective C have also been
> mentioned as use cases, and I can think of a variety of other uses such as
> database query mapping, predicate logic functions, and web or other types
> of RPC parameter marshalling.

I don't see annotations and decorators as falling in to the same
category in that respect. Decorators make life easier for a much wider
audience than do annotations. Everyone uses decorators, but how many
people write/use Java/ObjC bridges? Predicate logic functions? RPC
parameter marshaling?

Decorators took something that everyone was already doing and made it
easier. Taken together, the corpus of annotations use-cases still
represents a fairly rarefied subset of Python usage.

Maybe I'm wrong, though. A serious question to anyone doing a lot of,
e.g., RPC work: will annotations make your life easier? In what way?

Thanks,
Collin Winter

PS: I think it's interesting how nearly all the use-cases mentioned
involve adding type information to functions.


More information about the Python-3000 mailing list