Skip to content

[mypyc] Merge fast_isinstance_op and py_calc_meta_op #9662

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 2 commits into from
Nov 3, 2020
Merged

[mypyc] Merge fast_isinstance_op and py_calc_meta_op #9662

merged 2 commits into from
Nov 3, 2020

Conversation

TH3CHARLie
Copy link
Collaborator

relates mypyc/mypyc#753

This PR merges two remaining misc ops.

The problem with these two is that they rely on inlined PyTypeObject * cast during the call, while the casted object has already gone through a cast from PyTypeObject * to PyObject * before the function call(due to the highly C-coupled design in some other parts of the IR).

Thus, I think the best way(at least for now) is to use inline wrappers to merge these two ops, avoiding introducing over-complicated designs for only these two ops.

@TH3CHARLie TH3CHARLie requested a review from JukkaL October 29, 2020 16:45
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! The use of inline functions as a stopgap measure is a good idea, and it will allow us to remove the old primitive machinery.

Just one comment about a TODO command and/or issue about one of the inline functions.

}

static inline PyObject *CPy_CalculateMetaclass(PyObject *type, PyObject *o) {
return (PyObject *)_PyType_CalculateMetaclass((PyTypeObject *)type, o);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This use of casts is a good way to work around the pointer type mismatches, and it's not a problem if we can't inline this on non-C backends, since this isn't performance critical.

@TH3CHARLie
Copy link
Collaborator Author

The issue: mypyc/mypyc#774

@TH3CHARLie TH3CHARLie merged commit 52702e5 into python:master Nov 3, 2020
@TH3CHARLie TH3CHARLie deleted the type-object-related-op branch November 3, 2020 05:49
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