Re:PHP 7's new hashtable implementation
by ape4 on Tuesday December 23, 2014 @03:43AM
(#8787334)
I assumed they used C++ std::map<>
[ Parent
| on HN ]
PHP isn't written in C++. It's written in some pretty macro dense C. Even if it were, <map> isn't a hash table.
But std::unordered_map is. I wonder what would be the actual C++ memory consumption using that.
Re:PHP 7's new hashtable implementation
by sharpneli on Tuesday December 23, 2014 @11:54AM
(#8788884)
C++ unordered map does not maintain the order of the elements, which PHP does. So it is not a fair comparison.
Something approximately equivalent would be Boosts multi_index with a couple of indexes.
using php_array_t = multi_index_container<
int64_t,
indexed_by<
random_access<>,
hashed_unique<identity<int64_t>>
>
>;
There are so many design considerations at play though that such a comparison would be pointless.