This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author masamoto
Recipients EdSchouten, erik.bray, masamoto, ncoghlan, r.david.murray, vstinner
Date 2017-07-19.14:02:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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

Date User Action Args
2017-07-19 14:02:49masamotosetrecipients: + masamoto, ncoghlan, vstinner, r.david.murray, erik.bray, EdSchouten
2017-07-19 14:02:49masamotosetmessageid: <>
2017-07-19 14:02:49masamotolinkissue25658 messages
2017-07-19 14:02:48masamotocreate