Author masamoto
Recipients EdSchouten, erik.bray, haypo, masamoto, ncoghlan, r.david.murray
Date 2017-07-19.14:02:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1500472969.55.0.764947886513.issue25658@psf.upfronthosting.co.za>
In-reply-to
Content
Nick and Erik, thank you for the comments! I merged proposal into the PR.

Well, I'm interested in the hide implementation detail for TSS API (lately, I've read the python-ideas thread "PEP: Hide implementation details in the C API" which Victor opened [1]).

Present, the draft of new API has given two methods for thread key initialization for the non-limited API (i.e. Py_tss_NEEDS_INIT for statically, PyThread_tss_alloc for dynamic). The static initialization needs implementation detail for thread key, but Py_tss_t is designed as an opaque data type based on the stable ABI and we don't feel like to open the implementation detail to the API client. On the other hand, we'd provide newly thread key (de-)allocation functions for the limited API, the API client is able to get an initialized value without knowing thread key detail. And also the functions can be used on the non-limited API.

Therefore, I think it makes more sense that all API clients use PyThread_tss_(alloc|free) regardless of the limited API. The reason is which are (1) Py_tss_t behaves as an opaque data type as expected for any API client (cannot read and write directly the fields in any case), (2) the API gets more consistency (just one method for key initialization on the API client).

TL;DR: I'd suggest to make key type strict, what do you think about below changes?

- replace Py_LIMITED_API with Py_BUILD_CORE on Python/pythread.h Py_tss_t definition
- use PyThread_tss_(alloc|free) in Modules/_tracemalloc.c
- also use in Modules/_testcapimodule.c

[1] https://mail.python.org/pipermail/python-ideas/2017-July/046399.html
History
Date User Action Args
2017-07-19 14:02:49masamotosetrecipients: + masamoto, ncoghlan, haypo, r.david.murray, erik.bray, EdSchouten
2017-07-19 14:02:49masamotosetmessageid: <1500472969.55.0.764947886513.issue25658@psf.upfronthosting.co.za>
2017-07-19 14:02:49masamotolinkissue25658 messages
2017-07-19 14:02:48masamotocreate