Skip to content
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

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

Open
jbrockmendel opened this issue Dec 21, 2019 · 1 comment
Open

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

jbrockmendel opened this issue Dec 21, 2019 · 1 comment

Comments

@jbrockmendel
Copy link
Contributor

@jbrockmendel jbrockmendel commented Dec 21, 2019

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

This comment has been minimized.

Copy link
Contributor

@scoder 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.