# Specify \`TYPE\_CHECKING = False\` without typing import

**URL:** <https://discuss.python.org/t/specify-type-checking-false-without-typing-import/76766>\
**Category:** Typing\
**Created:** [January 11, 2025, 7:42am UTC](https://discuss.python.org/t/specify-type-checking-false-without-typing-import/76766 "2025-01-11T07:42:44Z")\
**Posts on this page:** 1\
**Showing post:** 34

<div class="post-metadata">

**Author:** ![methane](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/methane/32/43_2.png) [@methane](https://discuss.python.org/u/methane)\
**Post date:** [March 14, 2025, 1:17am UTC](https://discuss.python.org/t/specify-type-checking-false-without-typing-import/76766/34 "2025-03-14T01:17:34Z")

</div>

I prefer adding ` __type_checking__ ` **constant** , not builtin.

For example, SQLAlchemy is large library, and uses a lot of `if TYPE_CHECKING:`.  
See [elements.py](https://github.com/sqlalchemy/sqlalchemy/blob/main/lib/sqlalchemy/sql/elements.py) for example.

When replacing `if (typing\.)?TYPE_CHECKING` with `if False`, bytecode size reduced about 4%.

```python
$ wc -c *.pyc
  211087 elements.cpython-313.pyc # original
  192163 elements_false.cpython-313.pyc # replaced with `if False`

```

But `if False` is not looks good for readability.  
This expression does not clearly express the intention.

Adding constant allow us to add rich type hints with zero runtime cost.

---

_[View the full topic](https://discuss.python.org/t/specify-type-checking-false-without-typing-import/76766)._
