Skip to content

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

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 1 commit into from
Aug 5, 2021

Conversation

jhance
Copy link
Collaborator

@jhance jhance commented Aug 4, 2021

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.

Copy link
Collaborator

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

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