Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable UP038 Ruff rule to avoid introducing slower code #5020

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

luzfcb
Copy link
Collaborator

@luzfcb luzfcb commented Apr 23, 2024

Description

Disable the UP038 Ruff rule to avoid introducing valid code, which is slower due to the lack of optimization in the Python interpreter itself.

This rule also does not exist in pyupgrade for the same reason.

Checklist:

  • I've made sure that tests are updated accordingly (especially if adding or updating a template option)
  • I've updated the documentation or confirm that my change doesn't require any updates

Rationale

Although Python 3.10 starts to support the use of Union in isinstance and issubclass, there is a considerable performance loss compared to using tuple, which has not yet been fully resolved in the Python interpreter.

Python 3.11 has improved performance but is still 4x slower than using tuples. Maybe it will be resolved in Python 3.13.
Check astral-sh/ruff#7871

Copy link
Collaborator

@foarsitter foarsitter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@foarsitter foarsitter merged commit 00ecfc5 into master Apr 24, 2024
14 checks passed
@foarsitter foarsitter deleted the luzfcb-disable-UP038-ruff-rule branch April 24, 2024 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants