Re: [RFC] [Discussion] array_match

From: Date: Sun, 23 Aug 2026 15:25:08 +0000
Subject: Re: [RFC] [Discussion] array_match
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-132306@lists.php.net to get a copy of this message
Am 23.08.2026 um 17:50 schrieb ⁨سپهر محمودی⁩ <⁨sepehrphpr@gmail.com⁩>: > However, my main motivation for this RFC is performance. When dealing with large arrays, the > overhead of executing a callback (even a built-in one) for every single element in > array_filter can be quite significant. A dedicated function > implemented purely in C would bypass that overhead and execute much faster. Maybe you want to back this up with some benchmarks of real world cases you had to deal with. Personally, we are dealing with large files and in our experience the bottle neck is more often memory than speed. This means we often use a streaming approach for large data sets to avoid having the whole data in memory. Which wouldn't work well with your proposed function and the performance impact would probably negligible. > Do you think the performance gain for such a common use-case justifies having a dedicated > function, or do you feel the language should strictly prefer the > array_filter approach despite the overhead? I think the performance of array_filter is good enough for 99% of the cases, preg_grep (which in most cases will be simple enough if the search string is a fixed string) is good enough for 99% of the remaining performance critical cases which dissuades me from adding another function for the remaining 0.01%. Regards, - Chris

« previous php.internals (#132306) next »