5 ms·
Did you know that each integer in a PHP array takes 68 bytes of storage?
- marketer 19y agoTry opening up a python interpreter and running help(int). You'll notice something surprising -- there are over 50 methods available for ints. This ranges from all the basic math operations, shifts, boolean operations, and high precision math functions. The actual data itself is small, either 4 or 8 bytes, depending on the architecture. Now, depending on the language php was written in (I believe it is C), the other ~60 bytes is probably has metadata associated with all the operations.
- aston 19y agoKinda misleading title. It's not the int, it's the int in an array. Or, more precisely, in a hash table, since PHP doesn't actually have strictly-numerically-indexed vectors.
- lst 19y agoI hardly recommend using PHP for number crunching to all of my competitors.
- nwinter 19y agoInterestingly enough, as far as I know, Python ints and floats each take up a cumulative 20 bytes.