<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 17 December 2016 at 03:51, Antoine Pitrou <span dir="ltr"><<a href="mailto:solipsis@pitrou.net" target="_blank">solipsis@pitrou.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Fri, 16 Dec 2016 13:07:46 +0100<br>
Erik Bray <<a href="mailto:erik.m.bray@gmail.com">erik.m.bray@gmail.com</a>> wrote:<br>
> Greetings all,<br>
><br>
> I wanted to bring attention to an issue that's been languishing on the<br>
> bug tracker since last year, which I think would best be addressed by<br>
> changes to CPython's C-API. The original issue is at<br>
> <a href="http://bugs.python.org/issue25658" rel="noreferrer" target="_blank">http://bugs.python.org/<wbr>issue25658</a>, but I have made an effort below in<br>
> a sort of proto-PEP to summarize the problem and the proposed<br>
> solution.<br>
><br>
> I haven't written this up in the proper PEP format because I want to<br>
> see if the idea has some broader support first, and it's also not<br>
> clear to me whether C-API changes (especially to undocumented APIs)<br>
> even require their own PEP.<br>
<br>
</span>This is a nice detailed write-up and I'm in favour of the proposal.<br></blockquote><div><br></div></div>Likewise - we know the status quo isn't right, and the proposed change addresses that. In reviewing the patch on the tracker, the one downside I've found is that due to "pthread_key_t" being an opaque type with no defined sentinel, the consuming code in _tracemalloc.c and pystate.c needed to add separate boolean flag variables to track whether or not the key had been created. (The pthread examples at <a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_key_create.html">http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_key_create.html</a> use pthread_once for a similar effect)<br><br></div><div class="gmail_extra">I don't see any obvious way around that either, as even using a small struct for native pthread TLS keys would still face the problem of how to initialise the pthread_key_t field.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Cheers,<br></div><div class="gmail_extra">Nick.<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature">Nick Coghlan | <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a> | Brisbane, Australia</div>
</div></div>