[issue42525] Optimize class/module level annotation

2020-12-20 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue42525] Optimize class/module level annotation

2020-12-20 Thread Yurii Karabas
Yurii Karabas <1998uri...@gmail.com> added the comment: After several attempts to optimize class/module annotations, I didn't find a solution that won't break existing code and can cover all existing edge cases. The root cause was mentioned by Inada, the problem that `__annotations__` is

[issue42525] Optimize class/module level annotation

2020-12-03 Thread Batuhan Taskaya
Change by Batuhan Taskaya : -- nosy: +pablogsal ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42525] Optimize class/module level annotation

2020-12-03 Thread Batuhan Taskaya
Batuhan Taskaya added the comment: > For instance, we have such code: But what about this, what would the bytecode will look like in this case (where the annotations don't exactly follow each other?) a: int T = TypeVar('T') b: T b1: Gen[T] X = TypeVar('X') c: X d: str Do you propose to

[issue42525] Optimize class/module level annotation

2020-12-03 Thread Yurii Karabas
Yurii Karabas <1998uri...@gmail.com> added the comment: As all annotations are known at compilation time we can optimize annotations creating. For instance, we have such code: ``` a: int b: int ``` With the current implementation, we will have such bytecode: ``` 1 0

[issue42525] Optimize class/module level annotation

2020-12-01 Thread Inada Naoki
Inada Naoki added the comment: I agree with Batuhan. Although bytecode for class annotations seems inefficient, it is difficult to optimize without breaking backward compatibility. You can write arbitrary code in class/module block which dynamically manipulate __annotations__. ``` class

[issue42525] Optimize class/module level annotation

2020-12-01 Thread Batuhan Taskaya
Batuhan Taskaya added the comment: Would it require a substantial amount of changes? If so, I don't think this is a critical optimization since nearly-all of class definitions happens on the module level and evaluated on the import time only once. -- nosy: +BTaskaya

[issue42525] Optimize class/module level annotation

2020-12-01 Thread Yurii Karabas
New submission from Yurii Karabas <1998uri...@gmail.com>: This issue is inspired by https://bugs.python.org/issue42202 We can do smth similar for class/module level annotations. Inada Naoki what do you think regarding that? -- components: Interpreter Core messages: 382263 nosy: