Typing Annotations to django core (PEP 484)

109 views
Skip to first unread message

matthaus woolard

unread,
Mar 22, 2017, 8:43:22 AM3/22/17
to Django developers (Contributions to Django itself)

Django 2 will be for python 3.5+ this is the perfect time to start adding Typing Annotations to django core.

There is not need to add to the full code base at once, this is something that could be faced in as new apis are written and added to older apis and sages.

In my view advantages of adding the typing are 3 fold. 

1) makes the code easier to read
2) IDEs (that support this) will be better able to help users, true the existing type info from doc strings is used but the `typing` module provides more control such as generics and typed list/dicts etc
3) Once complete Django can use mypy to validate the types across the code base helping with reducing feature bugs through simple to fix typing issues.

Im not sure if there is any large performance hit from using typing on a large project like Django does anyone know of any performance metrics on this?

Florian Apolloner

unread,
Mar 22, 2017, 9:05:17 AM3/22/17
to Django developers (Contributions to Django itself)
Hi,


On Wednesday, March 22, 2017 at 1:43:22 PM UTC+1, matthaus woolard wrote:
1) makes the code easier to read

I disagree, they imo make the code harder to read, especially when the annotations are becoming a bit more complex.
 
Im not sure if there is any large performance hit from using typing on a large project like Django does anyone know of any performance metrics on this?

No, but if we use stub files for the annotations this should not be of any concern.

Cheers,
Florian

Tim Graham

unread,
Mar 22, 2017, 9:13:49 AM3/22/17
to Django developers (Contributions to Django itself)
Please search this mailing list's archives for past discussions, e.g. https://groups.google.com/d/topic/django-developers/trTEbURFhEY/discussion.
Reply all
Reply to author
Forward
0 new messages