[Python-3000] optional argument annotations

Tony Lownds tony at PageDNA.com
Thu Nov 23 21:27:48 CET 2006


On Nov 23, 2006, at 11:21 AM, Phillip J. Eby wrote:

> Why not just have the generated bytecode construct the annotation  
> dictionary directly and assign it to the returned function's  
> func_annotations, and the same for func_return if needed?  Then  
> there'd be no need to change the MAKE_FUNCTION opcode.  Mightn't  
> that make it easier to e.g. backport to the 2.x line, since it'd  
> only be a compiler change, not an interpreter or function type change?
>
>

It's more trips around the ceval loop and more constants on
the code object with the MAKE_FUNCTION opcode.

OTOH the mask stuff is pretty ugly. As a bonus, solving this problem  
is easier:

 >>> def f((x,y):1): pass
...
 >>> f.func_annotations
{'.0': 1}

I'm not sure how backwards compatibility is affected. MAKE_FUNCTION  
has already changed in p3yk.

It's worth a try though, thanks!

-Tony



More information about the Python-3000 mailing list