On 2022-06-21 13:53, David Mertz, Ph.D. wrote:
In the example, we assume that the built-in function `type()` is special
in not
counting as a reference to the binding for purpose of realizing a
computation.
Alternately, some new special function like `isdeferred()` might be used to
check for ``Deferred`` objects.

I'll have to ponder my thoughts about the proposal as a whole, but this particular aspect seems dubious to me. As I understand it this would require some fairly deep changes to how evaluation works in Python. Right now in an expression like `type(blah)`, there isn't any way for the evaluation of `blah` to depend on the fact that it happens to occur as an argument to `type`. The evaluation of the arguments of any function call happens before the function gets any say in the matter. For this proposal to work, that would have to change. Questions that immediately come to mind:

1. Would this also apply to the three-argument form of type? If not, then that makes the special-casing even more special.

2. What if I do `my_alias = type` and then do `my_alias(deferred_obj)`? Does that still not unwrap the thunk? What if I instead reassign the name `type` by doing `type = some_unrelated_func` and then call `type(deferred_obj)`? Now what happens?

3. Is there any way to write a new Python function that similarly bypasses un-thunking? Are there any other builtins that similarly bypass unthunking?

4. Why is this special-casing needed anyway? What would/could the surrounding code do differently with the deferred object based on knowing that it is deferred, since any other operations you would do it on would evaluate it anyway?

--
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail."
   --author unknown
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/II6OVWAGUBLL4B2WESYCBJ5WXT56BEW3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to