Skip to content

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commented Nov 7, 2023

@vstinner
Copy link
Member

Ping me when this PR is ready for review. Now it's marked as a draft.

@serhiy-storchaka
Copy link
MemberAuthor

It is ready for review. I marked it as draft because I do not insist that all these changes should be applied.

@serhiy-storchakaserhiy-storchaka marked this pull request as ready for review November 8, 2023 17:47
Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

LGTM

}
*presult = NULL;
return 0;
int rc = PyDict_GetItemRef(dict, key, presult);
Copy link
Member

Choose a reason for hiding this comment

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

_PyDict_GetItemProxy() now returns 1 if PyDict_GetItemRef() returns 1 and PyWeakref_CheckProxy() is false. It's only called once with if (_PyDict_GetItemProxy(cache, key, &result) != 0){. So it's ok.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, it has the same semantic as PyDict_GetItemRef().

1 -- found, returns a strong reference
0 -- not found (or was destroyed)
-1 -- error

}
*presult = NULL;
return 0;
int rc = PyDict_GetItemRef(dict, key, presult);
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, it has the same semantic as PyDict_GetItemRef().

1 -- found, returns a strong reference
0 -- not found (or was destroyed)
-1 -- error

@serhiy-storchakaserhiy-storchaka merged commit c98600b into python:mainNov 14, 2023
@serhiy-storchakaserhiy-storchaka deleted the use-dict_getitemref-in-ctypes branch November 14, 2023 09:28
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@serhiy-storchaka@vstinner