Is it possible for CPython to be aware of hint types?

As stated in PEP 484 :

Using type hints to optimize performance is left as an exercise for the reader.

Assuming that someone would be interested in this exercise, how difficult would it be, even partially? Is there a way to use hint type in an interpreted language to improve execution speed, or is this only possible when using a JIT compiler?

It should be noted that I also understand that this is not the goal and that:

Python will remain a dynamically typed language, and the authors have no desire to ever make type hints mandatory, even by convention.

Therefore, I understand that efforts to increase speed will contradict this by encouraging generic hints by convention. However, I am still curious about the difficulty of this task.

+3


source to share





All Articles