Skip to content

optimization: str(x) -> PyObject_Str(x) #3279

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

Closed
jbrockmendel opened this issue Dec 21, 2019 · 2 comments
Closed

optimization: str(x) -> PyObject_Str(x) #3279

jbrockmendel opened this issue Dec 21, 2019 · 2 comments

Comments

@jbrockmendel
Copy link
Contributor

AFAICT they are equivalent. Found a usage of PyObject_str here and it looks like the optimization isn't made in other places where we just do str(x).

I was happy to see that the usage of PyUnicode_Join was unnecessary.

@scoder
Copy link
Contributor

scoder commented Dec 22, 2019

Yes, they are equivalent.

The optimisation for the 1-argument case can follow this example:

def _handle_simple_function_unicode(self, node, function, pos_args):

Note that this needs to behave "as expected" for the three language levels 2, 3str and 3, but I think that should be ok. IIRC, str() gets mapped to unicode() (which is already optimised) in LL-3, but not in LL-2/3str, where the new optimisation would apply.

@scoder
Copy link
Contributor

scoder commented Apr 2, 2020

Implemented in #3478.

@scoder scoder closed this as completed Apr 2, 2020
@scoder scoder added this to the 3.0 milestone Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants