Re:How big are PHP arrays (and values) really?
by masklinn on Friday December 16, 2011 @06:52AM
(#3360428)
> Good info about Python, but you are incorrect about Ruby. Hashes and arrays are totally different in the Ruby implementations I know of.
From its context, I'm guessing samdk is saying:
> Ruby's hash and array implementations are similar [to Python's dict and list]
not that they're similar to one another, which would make absolutely no sense considering his comment starts with:
> Python and Ruby both have separate arrays and hashes.
so I'd say you agree with him and misread his comment.
EDIT: Sorry, I misread you. Ruby MRI and CPython are indeed similar.
At least in Ruby MRI (the mainline) arrays are implemented as a struct with a size and a pointer to a normal C array which contains the object references (references in MRI are pointers to object structs which use the lower bits to inline integers of <= 31 or 63 bits, true, false, nil and symbols).
Hashes in MRI I have not looked that much into but I believe they are a hash tables which in ruby 1.9 retain insertion order using pointers like a singly linked list.