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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to