mirror of https://github.com/astral-sh/ruff
Update UP038 docs to note that it results in slower code (#7872)
See discussion in #7871. I tried to use language similar to the existing performance warnings in the `flake8-use-pathlib` docs, e.g. https://docs.astral.sh/ruff/rules/os-path-abspath/#os-path-abspath-pth100
This commit is contained in:
parent
61a41334a3
commit
016e16254a
|
|
@ -39,9 +39,13 @@ impl CallKind {
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// Since Python 3.10, `isinstance` and `issubclass` can be passed a
|
/// Since Python 3.10, `isinstance` and `issubclass` can be passed a
|
||||||
/// `|`-separated union of types, which is more concise and consistent
|
/// `|`-separated union of types, which is consistent
|
||||||
/// with the union operator introduced in [PEP 604].
|
/// with the union operator introduced in [PEP 604].
|
||||||
///
|
///
|
||||||
|
/// Note that this results in slower code. Ignore this rule if the
|
||||||
|
/// performance of an `isinstance` or `issubclass` check is a
|
||||||
|
/// concern, e.g., in a hot loop.
|
||||||
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
/// isinstance(x, (int, float))
|
/// isinstance(x, (int, float))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue