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

bpo-1635741: Port _collections module to multiphase initialization. #19074

Merged
merged 3 commits into from
Mar 19, 2020

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Mar 19, 2020

@corona10
Copy link
Member Author

corona10 commented Mar 19, 2020

For the record, I will work on a new helper function after this PR is landed if this work is worth to do.
#19071 (comment)

@corona10 corona10 requested a review from vstinner March 19, 2020 15:40
@corona10
Copy link
Member Author

@shihai1991 Please take a look :)

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM apart "m" variable name which looks too short to me ;-)

if (PyType_Ready(type) < 0) {
return -1;
}
const char *name = _PyType_Name(type);
Copy link
Member

Choose a reason for hiding this comment

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

FYI I checked manually that the actual type name and _PyType_Name() gives the same name than before this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did same thing also :) Thank you for the re-checking!

}
const char *name = _PyType_Name(type);
Py_INCREF(type);
if (PyModule_AddObject(m, name, (PyObject *)type) < 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Checking for PyModule_AddObject() error is a good thing ;-)

_COLLECTIONS__COUNT_ELEMENTS_METHODDEF
{NULL, NULL} /* sentinel */
};

static int
collections_exec(PyObject *m) {
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: would you mind to rename it to "mod" or "module"?

Copy link
Member Author

Choose a reason for hiding this comment

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

module might be great! Thanks for the suggestion

@shihai1991
Copy link
Member

oh, on~ my network crashed at this point :(
I can not review codes now, waiting a moment~


defdict_type.tp_base = &PyDict_Type;

for (int i = 0; typelist[i] != NULL; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

nice improvment.

Copy link
Member

@shihai1991 shihai1991 left a comment

Choose a reason for hiding this comment

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

I like the improvment of typelist.
LGTM :)

@corona10
Copy link
Member Author

@vstinner @shihai1991

Thanks for the reviews :)

@vstinner vstinner merged commit 77248a2 into python:master Mar 19, 2020
@corona10 corona10 deleted the bpo-1635741-_collectionsmodule branch March 31, 2020 12: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.

5 participants