Skip to content

feat: new mypyc primitives for str.count #19264

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

Merged
merged 41 commits into from
Jul 1, 2025
Merged

Conversation

BobTheBuidler
Copy link
Contributor

@BobTheBuidler BobTheBuidler commented Jun 10, 2025

This PR adds new mypyc primitives for all variations of str.count

fixes 1096

@BobTheBuidler BobTheBuidler marked this pull request as ready for review June 10, 2025 05:16
@BobTheBuidler BobTheBuidler changed the title WIP: new mypyc primitives for str.count feat: new mypyc primitives for str.count Jun 10, 2025
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Looks good. Left some thoughts about additional cases to test.

string = "abcbcb"
assert string.count("a", 0, 4) == 1, string.count("a", 0, 4)
assert string.count("b", 0, 4) == 2, string.count("b", 0, 4)
assert string.count("c", 0, 4) == 1, string.count("c", 0, 4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideas for additional tests:

  • Test substrings with length longer than 1.
  • Test negative start/end (these appear to work).
  • Test start/end that overflows (these appear to not raise an exception).
  • Test unicode strings (e.g. character code larger than 127, character code larger than 255).

@BobTheBuidler
Copy link
Contributor Author

BobTheBuidler commented Jun 17, 2025

  • Test substrings with length longer than 1.
  • Test negative start (these appear to work).
  • Test negative end (these appear to work).
  • Test start/end that overflows (these appear to not raise an exception).
  • Test unicode strings (e.g. character code larger than 127, character code larger than 255).

@BobTheBuidler
Copy link
Contributor Author

All requested tests have been added, this PR is now ready for review.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! Looks good now.

@JukkaL JukkaL merged commit 3df3d79 into python:master Jul 1, 2025
13 checks passed
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.

Add primitive for str.count
2 participants