Re: Request for couple memory optimized array improvements
| From: | Josh Bruce | Date: | Tue, 01 Sep 2020 15:26:45 +0000 |
| Subject: | Re: Request for couple memory optimized array improvements | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111765@lists.php.net to get a copy of this message | ||
That’s interesting as I haven’t played with iterates and generators much.
If the iterator can’t take an iterable, the idea of something like __toArray seems way more
convenient: https://wiki.php.net/rfc/to-array
Cheers,
Josh
> On Aug 31, 2020, at 4:39 PM, Michael Voříšek - ČVUT FEL <vorismi3@fel.cvut.cz> wrote:
>
> I would highly prefer php optimalization for it. ArrayKeysIterator can
> not even used if the input is iterable instead of pure array.
> With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem,
>
> Michael Voříšek
>
>> On 31 Aug 2020 23:31, Max Semenik wrote:
>>
>>> On Mon, Aug 31, 2020 at 11:53 PM Michael Voříšek - ČVUT FEL
>>> <vorismi3@fel.cvut.cz> wrote:
>>> Optimizing foreach (array_keys($arr) as $k) is very important, not only
>>> because of memory, but because of speed when not all elements needs to
>>> be iterated, like: foreach (array_keys($arr) as $k) { if ($k some condition) { break; }
>>> }
>> Can an iterator be the answer? E.g. foreach (new ArrayKeysIterator($arr) as $k) { ... } --
>> Best regards,
>> Max Semenik