KEMBAR78
[mypyc] Faster len(bytes) by 97littleleaf11 · Pull Request #10936 · python/mypy · GitHub
Skip to content

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.



[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