Specify `TYPE_CHECKING = False` without typing import

I don’t see how putting the typing imports into a TYPE_CHECKING block is lying about anything.

I see this sort of attitude a lot whenever anyone talks about speed in Python. I guess there are two different approaches that people take to the idea that Python is slow:

  • Maybe we should make things faster or reduce unnecessary overheads.
  • Maybe we should just give up and let everything become slower and slower.

You can use Python to wrap up C/Rust etc code but whatever you do to accelerate the heavy lifting a simple CLI program is very often limited by startup overhead. Every time someone decides that it’s okay to waste a bit more time here and there by making different parts of startup slower it all adds up.

If people took the attitude that runtime performance does actually matter then I think a lot of things would be designed differently. Instead every time a discussion about performance comes up people will call into question even the notion that anyone should care about it because “use a different language if you care about that”. If you don’t care about performance then it is inevitable that things will end up being slow.

22 Likes