Skip to content

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Nov 7, 2023

current_param = PyObject_GetItem(parameters, binding_name_obj);
}
PyObject *current_param;
(void)PyMapping_GetOptionalItem(parameters, binding_name_obj, &current_param);
Copy link
Member Author

Choose a reason for hiding this comment

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

PyMapping_GetOptionalItem() includes a special case for dict, so there is no performance loss.

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

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

Thanks; the resulting code is cleaner, thus positively affecting readability and maintainability.

@serhiy-storchaka
Copy link
Member Author

It can be even more simplified if use PyMapping_GetOptionalItemString().

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) November 10, 2023 20:29
@serhiy-storchaka serhiy-storchaka merged commit afac3c9 into python:main Nov 10, 2023
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Use new C API functions PyDict_GetItemRef() and
PyMapping_GetOptionalItemString().
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Use new C API functions PyDict_GetItemRef() and
PyMapping_GetOptionalItemString().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants