Skip to content

[mypyc] Faster len(bytes) #10936

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 3 commits into from
Aug 5, 2021
Merged

Conversation

97littleleaf11
Copy link
Collaborator

@97littleleaf11 97littleleaf11 commented Aug 5, 2021

Description

Similar to list and tuple, we can directly get length of bytes from PyVarObject->ob_size

Implements part of mypyc/mypyc#880.

Test Plan

  • Add an irbuild test
  • Add run tests for bytearray(There are already several run tests for bytes)

@97littleleaf11 97littleleaf11 changed the title Add bytes len [mypyc] Faster len(bytes) Aug 5, 2021
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.

Looks good, just one nit about the IR build test case.

@@ -62,14 +62,27 @@ L0:
c = r6
return 1


[case testBytesJoin]
[case testBytesOps]
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to have a separate test case for len(), since irbuild tests are fast to run. Small test cases are generally easier to maintain.

It's important to not have too many small run tests, however, since they have a lot of fixed overhead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@JukkaL JukkaL merged commit baea65a into python:master Aug 5, 2021
@97littleleaf11 97littleleaf11 deleted the add-bytes-len branch August 5, 2021 12:52
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