-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Hello,
I think we can save some time and memory on large data sets by using iterators instead of arrays here:
https://github.com/functional-php/parallel/blob/master/src/functions.php#L75
If we provide an iterator (from a DB statement for example), we have to traverse it once in the iterator_to_array statement, then array_chunk make use traverse the data set once more.
Using iterators will not be a problem with array, as we already have \ArrayIterator class in SPL.
Moreover, instead of traversing two arrays here: https://github.com/functional-php/parallel/blob/master/src/functions.php#L59 , we could only traverse it once and apply the two functions in the same time.
BTW, a major part of the problem has already been solved in this (great) lib from nikic: https://github.com/nikic/iter/ (chunk, map and filter).
In the worst case, we could save 3 of 4 iterations. :-)
What do you think of this idea ? :-)