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

Skip to content

[mypyc] Add primitive for bytes join() method - #10929

Merged
msullivan merged 1 commit into
python:masterfrom
jhance:bytes-join
Aug 5, 2021
Merged

[mypyc] Add primitive for bytes join() method#10929
msullivan merged 1 commit into
python:masterfrom
jhance:bytes-join

Conversation

@jhance

@jhance jhance commented Aug 4, 2021

Copy link
Copy Markdown
Collaborator

Description

This is mostly adapted from how it is done for str. We call undocumented API function _CPyBytes_Join which behaves similarly to the publicly available unicode one. Care is taken to deal with the case where we happen to have bytearray instead. As a result of needing to do the CheckExact anyway, we also support wonky subclasses of bytes.

Test Plan

Added both ir and runtime tests. Benchmark yielded reasonable gains but the benchmark also included concat which is likely slower than join.

@msullivan msullivan 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

@msullivan

Copy link
Copy Markdown
Collaborator

(We should probably switch to using _PyObject_CallMethodIdObjArgs for all of our library method calls, though)

@msullivan
msullivan merged commit 97a1b3f into python:master Aug 5, 2021
@97littleleaf11

Copy link
Copy Markdown
Collaborator

Part of mypyc/mypyc#880.

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.

3 participants