[proxy] github.com← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
/ cpython Public

Conversation

Copy link
Member

pitrou commented Dec 19, 2017

return 1;
}


Copy link
Member

Choose a reason for hiding this comment

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

Unrelated change.

return NULL;
}
k = PyTuple_GET_SIZE(base->tp_mro);
result = PyTuple_New(k + 1);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the result be a tuple?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean a list? The caller calls PySequence_Tuple on the result, so it's faster if we create a tuple upfront.

return mro_implementation(self);
PyObject *seq;
seq = mro_implementation(self);
if (seq != NULL && PyTuple_CheckExact(seq)) {
Copy link
Member

Choose a reason for hiding this comment

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

I would write !PyList_Check().

PyObject *seq;
seq = mro_implementation(self);
if (seq != NULL && PyTuple_CheckExact(seq)) {
PyObject *lst = PySequence_List(seq);
Copy link
Member

Choose a reason for hiding this comment

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

This may look clearer with

Py_SETREF(seq, PySequence_List(seq));

and a single return.

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 have to get used to it :-)

pitrou merged commit 1f1a34c into python:master Dec 20, 2017
pitrou deleted the faster_mro_impl branch December 20, 2017 14:58
Copy link
Member Author

pitrou commented Dec 20, 2017

Thanks for the review @serhiy-storchaka !

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.

4 participants