r/Python • • May 30 '19

Dear python2 user

Post image
1.9k Upvotes

275 comments sorted by

View all comments

Show parent comments

-70

u/mmarius90 May 30 '19

In total agreement with you except for the type annotations. I see those as an abomination. Python is so beautiful as a syntax without those horrible glyphs.

Quote the PEP:

While these annotations are available at runtime through the usual annotations attribute, no type checking happens at runtime . Instead, the proposal assumes the existence of a separate off-line type checker which users can run over their source code voluntarily

See? An abomination. I'll never introduce those in my personal projects.

7

u/[deleted] May 30 '19

Maybe they aren't as useful as they could be, but how else could you write typed code without a performance penalty?

If you checked type at runtime everything would slow to a glacial crawl...

0

u/cj81499 May 30 '19

runtime type checking doesn't sound to me like something that would take a lot of time. Care to explain why you think this?

2

u/alkasm github.com/alkasm May 30 '19

Not for single objects, no---but think of data structures. Is it going to check that every element in a list is an int? What if the list has a million elements?

→ More replies (6)