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

Slight speed-up for lowercase and uppercase identifier checks #9798

Merged
merged 1 commit into from
Feb 3, 2024

Conversation

charliermarsh
Copy link
Member

It turns out that for ASCII identifiers, this is nearly 2x faster:

Parser/before     time:   [15.388 ns 15.395 ns 15.406 ns]
Parser/after      time:   [8.3786 ns 8.5821 ns 8.7715 ns]

@charliermarsh charliermarsh added the performance Potential performance improvement label Feb 2, 2024
Copy link
Contributor

github-actions bot commented Feb 2, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check encountered linter errors. (no lint changes; 1 project error)

sphinx-doc/sphinx (error)

ruff failed
  Cause: Selection of unstable rules without the `--preview` flag is not allowed. Enable preview or remove selection of:
	- FURB113
	- FURB131
	- FURB132

Linter (preview)

✅ ecosystem check detected no linter changes.

@charliermarsh charliermarsh marked this pull request as ready for review February 2, 2024 20:43
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Now you're micro micro optimising. I'm not sure if this is worth the extra complexity

@charliermarsh
Copy link
Member Author

The counterargument is that we run this on every single identifier declared within every single function.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

LGTM. I don't mind the extra complexity so much in routines like this personally, because it's isolated and doesn't spread.

@charliermarsh
Copy link
Member Author

Need to add some non-ASCII tests (which we should have anyway).

@charliermarsh charliermarsh enabled auto-merge (squash) February 3, 2024 14:34
@charliermarsh charliermarsh merged commit 2352de2 into main Feb 3, 2024
16 checks passed
@charliermarsh charliermarsh deleted the charlie/str branch February 3, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Potential performance improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants