
On 1/11/21 4:55 PM, Greg Ewing wrote:
On 12/01/21 6:21 am, Larry Hastings wrote:
Unbound code objects --------------------
...The "annotation code object" is then stored *unbound* as the internal value of ``__co_annotations__``; it is then bound on demand when the user asks for ``__annotations__``.
This seems like premature optimisation. Function objects are tiny compared to the code object, which is already a fairly complicated thing composed of a number of sub-objects.
I'll have to let people with large code bases speak up about this, but my understanding is that most people would prefer Python to use less memory. On my 64-bit Linux machine, a code object is 136 bytes, its empty __dict__ is 64 bytes, and the other stuff you get for free. So that's 200 bytes even. Multiply that by 1000 and the back of my envelope says you've wasted 200k. Is that a big deal? I dunno. On the other hand, the code to support dynamically binding the code object on demand wasn't a big deal. Cheers, //arry/