[Python-ideas] Bad programming style in decorators?

Nick Coghlan ncoghlan at gmail.com
Tue Jan 5 00:55:00 EST 2016


On 5 January 2016 at 10:26, Guido van Rossum <guido at python.org> wrote:
> On Sat, Jan 2, 2016 at 10:42 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> Always allocating f.__annotations__ actually puzzled me a bit - did we
>> do that for a specific reason, or did we just not think of setting it
>> to None when it's unused to save space the way we do for other
>> function attributes? (__closure__, __defaults__, etc)
>
> Where do you see that happening? The code in funcobject.c seems to indicate
> that it's created on demand. (And that's how I remember it always being.)

I didn't check the code, only the behaviour, so I missed that querying
f.__annotations__ was implicitly creating the dictionary.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list