KEMBAR78
[mypyc] Add tests for string equality by JukkaL · Pull Request #19401 · python/mypy · GitHub
Skip to content

Conversation

@JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Jul 8, 2025

This is in preparation for adding a faster str equality primitive.

This is in preparation for adding a faster str equality primitive.
@JukkaL
Copy link
Collaborator Author

JukkaL commented Jul 8, 2025

I'm not going to wait for a review, since this just adds tests for existing functionality.

@JukkaL JukkaL merged commit 503f5bd into master Jul 8, 2025
13 checks passed
@JukkaL JukkaL deleted the mypyc-str-equal-tests branch July 8, 2025 13:00
JukkaL added a commit that referenced this pull request Jul 9, 2025
This speeds up self check by ~1.4%.  String equality is one of the top
five most common primitive function calls in self check.

We previously used a string comparison primitive that calculated the
relative order of two strings. Usually we only care about equality,
which we can do quicker since we can fast path using a length check,
for example.

I checked the CPython implementation of string equality in 3.9 (lowest
supported Python version) and 3.13, and both of them had a fast path
based on string object kind, and equality checks overall had the same
semantics.

Current CPython implementation:
https://github.com/python/cpython/blob/main/Objects/stringlib/eq.h

Tests for this were added in #19401.
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.

1 participant