KEMBAR78
[mypyc] Add primitive for bytes join() method by jhance · Pull Request #10929 · python/mypy · GitHub
Skip to content

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