[Python-ideas] Delayed Execution via Keyword

Joseph Hackman josephhackman at gmail.com
Fri Feb 17 11:43:31 EST 2017


Agreed. I think this may require some TLC to get right, but posting here for feedback on the idea overall seemed like a good start. As far as I know, the basic list and dict do not inspect what they contain. I.e. 

d = {}
d['a']= delayed: stuff()
b=d['a']

b would end up as still the thunk, and stuff wouldn't be executed until either d['a'] or b actually is read from. 

-Joseph

> On Feb 17, 2017, at 11:34 AM, Chris Angelico <rosuav at gmail.com> wrote:
> 
>> On Sat, Feb 18, 2017 at 3:29 AM, Joseph Hackman <josephhackman at gmail.com> wrote:
>> ChrisA: I am not sure about collections. I think it may be fine to not special case it: if the act of putting it in the collection reads anything, then it is evaluated, and if it doesn't it isn't. The ideal design goal for this would be that all existing code continues to function as if the change wasn't made at all, except that the value is evaluated at a different time.
>> 
> 
> Yeah, I'm just worried that it'll become useless without that. For
> instance, passing arguments to a function that uses *a,**kw is going
> to package your thunk into a collection, and that's how (eg) the
> logging module will process it.
> 
> It's not going to be easy to have a simple AND useful definition of
> "this collapses the waveform, that keeps it in a quantum state", but
> sorting that out is fairly key to the proposal.
> 
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/


More information about the Python-ideas mailing list