<div dir="auto">Keep MISSING.</div><div class="gmail_extra"><br><div class="gmail_quote">On Dec 28, 2017 8:44 AM, "Yury Selivanov" <<a href="mailto:yselivanov.ml@gmail.com">yselivanov.ml@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Dec 28, 2017 at 4:51 AM, Victor Stinner<br>
<<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I like the new version of the PEP using "read only mapping" and<br>
> copy_context(). It's easier to understand.<br>
<br>
Thanks, Victor!<br>
<br>
><br>
> I'm ok with seeing a context as a mapping, but I am confused about a context<br>
> variable considered as a mapping item. I still see a context variable as a<br>
> variable, so something which has a value or not. I just propose to rename<br>
> the default parameter of the ContextVar constructor.<br>
<br>
As Nathaniel already explained, a 'default' for ContextVars is<br>
literally a default -- default value returned when a ContextVar hasn't<br>
been assigned a value in a context.  So my opinion on this is that<br>
'default' is the less ambiguous name here.<br>
<br>
[..]<br>
><br>
> * a read-only attribute ``Token.old_value`` set to the value the<br>
>   variable had before the ``set()`` call, or to ``Token.MISSING``<br>
>   if the variable wasn't set before.<br>
><br>
><br>
> Hum, I also suggest to rename Token.MISSING to Token.NOT_SET. It would be<br>
> more conistent with the last sentence.<br>
<br>
I like MISSING more than NOT_SET, but this is very subjective, of<br>
course.  If Guido wants to rename it I rename it.<br>
<br>
<br>
> C API<br>
> -----<br>
><br>
><br>
> Would it be possible to make this API private?<br>
<br>
We want _decimal and numpy to use the new API, and they will call<br>
ContextVar.get() on basically all operations, so it needs to be as<br>
fast as possible.  asyncio/uvloop also want the fastest copy_context()<br>
and Context.run() possible, as they use them for *every* callback.  So<br>
I think it's OK for us to add new C APIs here.<br>
<br>
<br>
><br>
> 2. ``int PyContextVar_Get(PyContextVar *, PyObject *default_value,<br>
> PyObject **value)``:<br>
>     (...)  ``value`` is always a borrowed<br>
>    reference.<br>
><br>
><br>
> I'm not sure that it's a good idea to add a new public C function which<br>
> returns a borrowed reference. I would prefer to only use (regular) strong<br>
> references in the public API.<br>
<br>
Sure, I'll change it.<br>
<br>
Yury<br>
______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>guido%40python.org</a><br>
</blockquote></div></div>