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

[mypyc] Merge dict get op and generic power op #9347

Merged
merged 3 commits into from
Aug 25, 2020
Merged

[mypyc] Merge dict get op and generic power op #9347

merged 3 commits into from
Aug 25, 2020

Conversation

TH3CHARLie
Copy link
Collaborator

This PR merges get op with None as default value for dict, and a power op for generic numbers, which completes the support of generic_ops.py and dict_ops.py

@TH3CHARLie TH3CHARLie requested a review from JukkaL August 24, 2020 18:29
Copy link
Collaborator

@JukkaL JukkaL 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, just a minor comments. Feel free to merge after you've addressed the feedback.

@@ -63,6 +63,18 @@ PyObject *CPyDict_Get(PyObject *dict, PyObject *key, PyObject *fallback) {
return res;
}

PyObject *CPyDict_GetWithNone(PyObject *dict, PyObject *key) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about just calling CPyDict_Get in the body with an extra Py_None argument? The extra call should have minimal performance impact, and this would reduce some code repetition?

Declare the function in CPy.h.

@@ -35,3 +35,8 @@ PyObject *CPyIter_Next(PyObject *iter)
{
return (*iter->ob_type->tp_iternext)(iter);
}

PyObject *CPyNumber_Power(PyObject *base, PyObject *index)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declare this in CPy.h (it's unfortunate that this isn't caught by our tests).

@TH3CHARLie TH3CHARLie merged commit a72fca2 into python:master Aug 25, 2020
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.

2 participants