Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[mypyc] Faster len(bytes) - #10936

Merged
JukkaL merged 3 commits into
python:masterfrom
97littleleaf11:add-bytes-len
Aug 5, 2021
Merged

[mypyc] Faster len(bytes)#10936
JukkaL merged 3 commits into
python:masterfrom
97littleleaf11:add-bytes-len

Conversation

@97littleleaf11

@97littleleaf11 97littleleaf11 commented Aug 5, 2021

Copy link
Copy Markdown
Collaborator

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

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread mypyc/test-data/irbuild-bytes.test Outdated


[case testBytesJoin]
[case testBytesOps]

Copy link
Copy Markdown
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
Copy Markdown
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