Inada Naoki <songofaca...@gmail.com> added the comment:

> Are annotations now always known at compile time?

Yes, because `from __future__ import annotations` is enabled by default from 
Python 3.10.

> As for representation, it can also be a sequence of pairs (('x', 'int'), 
> ('z', 'float'), ('return', 'Hoge')) or a pair of sequences (('x', 'z', 
> 'return'), ('int', 'float', 'Hoge')). It would be better to save a dict 
> directly in pyc files, but it needs changing the marshal protocol.

Yes, but it is bit larger than my single tuple idea in most cases.
Since most annotations are not used by runtime, we don't need to create a dict 
until `func.__annotation__` is read.

> Also, it makes sense to make annotations attribute of the code object, so 
> avoid the overhead at function creation time.

I am not sure this is the best option because there are many code object 
without annotation.

> I have a dream to split the pyc file into several files or sections and save 
> docstrings and annotations (and maybe line numbers) separately from the main 
> code. They should be loaded by demand, when you read __doc__ or 
> __annotation__. Most code does not use them at run time, so we can save 
> memory and loading time. It can also help with internationalization.

I have same dream.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42202>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to