Array design question

Thomas Bellman bellman at lysator.liu.se
Fri May 30 07:09:48 EDT 2003


Peter Slizik <peter.slizik at pobox.sk> wrote:

> If you are trying to suggest that PHP uses hashes also in the case of 
> integer indexing, I feel ... how to put it ... cheated?

The first sentence in the PHP manual about arrays says:

    An array in PHP is actually an ordered map.

(http://www.php.net/manual/en/language.types.array.php)

A small test also implies that it at least doesn't use an
ordinary vector implementation even when only using only integer
indices, but at least some datastructure for sparse arrays.
Otherwise,

    <?php
    $arr = array();
    $arr[0] = "a";
    $arr[1000000000] = "b";
    $arr[2000000000] = "c";
    echo $arr[0];
    echo $arr[2000000000];
    echo $arr[1000000000];
    ?>

shouldn't work very well on my workstation, since it should use
about 8 Gbyte of memory, and I only have 96 Mbyte RAM, 1 Gbyte
swap, and only 32 bit adressing.

So I suspect you should start feeling cheated...

(However, I don't actually know any PHP.  I just surfed my way to
the PHP manual and read the section about arrays.)


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
"God is real, but Jesus is an integer."      !  bellman @ lysator.liu.se
                                             !  Make Love -- Nicht Wahr!




More information about the Python-list mailing list