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

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

BobTheBuidler
Copy link

@BobTheBuidler BobTheBuidler commented Jun 10, 2025

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

@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).

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.

2 participants