Re: [RFC] [Discussion] Add new function `array_group`
| From: | Boro Sitnikovski | Date: | Tue, 30 May 2023 17:42:14 +0000 |
| Subject: | Re: [RFC] [Discussion] Add new function `array_group` | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120475@lists.php.net to get a copy of this message | ||
> On 30.5.2023, at 19:21, Larry Garfield <larry@garfieldtech.com> wrote:
>
> On Tue, May 30, 2023, at 4:27 PM, Boro Sitnikovski wrote:
>> Hi,
>>
>> Thank you for your thoughts.
>>
>>> I would say the more common desired behavior is the one in your first
>>> example. And even for that we don't have a native function.
>>
>> This Google search might give more insight into the number of
>> discussions about a grouping functionality:
>>
>> https://www.google.com/search?q=php+group+elements+site:stackoverflow.com
>>
>>> Your behavior can be implemented in userland like so:
>>> https://3v4l.org/epvHm
>>
>> Correct, but then again, we can also implement
>>
array_map/array_filter/etc.
>> in userland :)
>>
>>> I think you need to make a case as to why the behavior you describe
>>> justifies a native function.
>>
>> Similar to my previous answer, but also in general - ease of access and
>> also performance.
>
> Do you have benchmarks showing that implementing it in C would be notably faster? That would
> help the case that it should be written in C.
>
> Also, please do not top-post.
>
> --Larry Garfield
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
Sorry for the top-posting, my bad.
I ran some performance benchmarks and the improvement is about 25% - some details on the following
gist: https://gist.github.com/bor0/3fa539263335fa415faa67606a469f2e?permalink_comment_id=4584327#gistcomment-4584327