On Tue, 29 Dec 2020 at 18:04, tyson andre <tysonandre...@hotmail.com> wrote:

> Hi Internals,
>
> Currently, PHP doesn't have a built in memory-efficient array type with
> convenient push, pop, and other operations, similar to a list/vector in
> other languages.
> The closest built in in SPL is [SplFixedArray](
> https://www.php.net/manual/en/class.splfixedarray.php)
>
> https://www.php.net/manual/en/class.splstack.php uses a doubly linked
> list, which uses much more memory and time than sequential memory.
>
> Contrary to the name and description in
> https://www.php.net/manual/en/class.splfixedarray.php, the class is
> already resizable.
> The resize method is setSize -
> https://www.php.net/manual/en/splfixedarray.setsize.php
> (increasing size is efficient - erealloc will extend the underlying array
> into free memory if there is nothing in the way)
>
> Many programming languages have a memory-efficient list/vector type that
> can be conveniently appended to and popped from.
>
> https://docs.python.org/3/tutorial/datastructures.html#more-on-lists
> https://www.cplusplus.com/reference/vector/vector/
> https://docs.ruby-lang.org/en/2.0.0/Array.html#method-i-push
>
> Is there any interest in adding this? It would be much more efficient to
> add these in C.
>
> Thanks,
> - Tyson
>

Hi Tyson,

Did you have a look at ext-ds? It provides several very efficient data
structures:
https://github.com/php-ds/ext-ds

I would love if this extension could find its way into core, actually.

Kind regards,
Benjamin

Reply via email to