On Thu, Feb 11, 2021 at 5:47 AM tyson andre <tysonandre...@hotmail.com> wrote:
> Hi internals, > > I've created a new RFC https://wiki.php.net/rfc/cachediterable adding > CachedIterable, > which eagerly evaluates any iterable and contains an immutable copy of the > keys and values of the iterable it was constructed from > > > Any other feedback unrelated to namespaces? > > Thanks, > - Tyson > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > Hi Tyson, I needed this feature a few years ago. In that case, the source was a generator that was slowly generating data while fetching them from a paginated API that had rate limits. The result wrapping iterator was used at runtime in multiple (hundreds) other iterators that were processing elements in various ways (technical analysis indicator on time series) and after that merged back with some MultipleIterator. Just for reference, this is how the implementation in userland was and I was happy with it as a solution: https://gist.github.com/drealecs/ad720b51219675a8f278b8534e99d7c7 Not sure if it's useful but I thought I should share it as I noticed you mentioned in your example for PolyfillIterator you chose not to use an IteratorAggregate because complexity Was wondering how much inefficient this would be compared to the C implementation. Also, the implementation having the ability to be lazy was important and I think that should be the case here as well, by design, especially as we are dealing with Generators. Regards, Alex