[Python-ideas] Delayed Execution via Keyword

Nathaniel Smith njs at pobox.com
Sat Feb 18 06:10:09 EST 2017

On Fri, Feb 17, 2017 at 9:34 PM, David Mertz <mertz at gnosis.cx> wrote:
> On Fri, Feb 17, 2017 at 6:20 PM, Nathaniel Smith <njs at pobox.com> wrote:
>> value = delayed: some_dict.get("whatever")
>> if value is None:
>>     ...
>> I.e., the question is, how does 'is' work on delayed objects? I guess
>> it has to force the promise and walk the proxy chain in each input and
>> then do an 'is' on the base objects?
> You've explained the semantics exactly.  That's not confusing at all.

Okay... so what if I want to check if two objects refer to the same
delayed computation? I guess you can say that's just not supported,
but that's *extraordinarily weird* for Python.

And at the implementation level... so you just added two type checks
and two branches to every 'is' call; this seems concerning. And now
'is' can raise an error, which it never could before. You also AFAICT
have to modify every single C extension function to check for and
handle these things, which is probably impossible even if the overhead
of all the checks is acceptable, which isn't obvious. I'm just not
seeing how this could be implemented.


Nathaniel J. Smith -- https://vorpus.org

More information about the Python-ideas mailing list