Why is typing.cast
an actual function?
#1146
Unanswered
arceusspike
asked this question in
Q&A
Replies: 2 comments 8 replies
-
You're welcome to propose an alternative syntax. The current syntax using a function call fits naturally in any expression, and the overhead of a simple function call is not a huge problem for much code. You may be interested in python/cpython#27474. |
Beta Was this translation helpful? Give feedback.
4 replies
-
No idea if it ever has been proposed, but what I'd like to see for |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Why add the overhead of a function call when it adds no functionality to the program at runtime? Couldn’t we tell the type-checking program to treat the variable passed to
cast
as some type via some kind of inline type hint that the interpreter knows to ignore? I don’t understand why static typing would need to interfere with and degrade runtime, but I’m sure I am missing something that is obvious to others.Beta Was this translation helpful? Give feedback.
All reactions