Re: RFC Draft: Comprehensions

From: Date: Thu, 21 Mar 2019 00:39:20 +0000
Subject: Re: RFC Draft: Comprehensions
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-104836@lists.php.net to get a copy of this message
> > Hi! > > > >> It's not that you can't make an array into a generator, but you can't > >> make > >> an eagerly-evaluated expression into a lazily-evaluated one. > > Not sure what you mean here. > > > I mean that, given a syntax that lazily-evaluates something, you can > "fast-forward" the result to make it eagerly-evaluated; given a syntax > that eagerly-evaluates something, you cannot do the opposite. Therefore, > a lazy-evaluating syntax is more powerful, in that it can do everything > an eager-evaluating one can do *and more*. > For my use case of PHP, get some content from a DB and dump it into a template, I don't see much benefit to generators. Such content is textual and is small relative to available ram. Memory locality also matters for performance and it is generally faster to do a whole bunch of stuff at once, thus I'd expect an eager version to be faster than a generator. I'm almost sure it would be faster if stepping the generator entailed IPC, reaching out to a database for instance.

« previous php.internals (#104836) next »