Hacker News new | past | comments | ask | show | jobs | submit login

PHP arrays are associative arrays, it has to update the keys for every remaining value after the first element is deleted.



PHP does at least have an optimised internal representation for arrays with sequential integer keys, where it can avoid having a hash table and just do linear indexing: https://www.npopov.com/2014/12/22/PHPs-new-hashtable-impleme...

But a tradeoff in that design is it still has to keep track of keys and update them if you remove stuff from the start of the array. Adding and removing elements at the end is very fast, though.


That seems like some kind of local fitness minimum in the space of design choices. Even though there certainly are worse choices one could make, I couldn't imagine anything much worse than that would even stand up to any sort of use.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: