Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify usage/advantage over standard PHP arrays #24

Open
patrickallaert opened this issue Aug 17, 2015 · 0 comments
Open

Clarify usage/advantage over standard PHP arrays #24

patrickallaert opened this issue Aug 17, 2015 · 0 comments

Comments

@patrickallaert
Copy link

I have found in README.md the "how", but not the "why".

Being a "Sparse array" implementation, I would expect that it would be much more memory efficient to do:

$array = new Judy(Judy::INT_TO_INT);
for ($i = 0; $i < 100000; ++$i) {
    $array[$i] = 0;
}
$array[42] = 42;
$array[420] = 420;

over:

$array = []; // <== this line differs
for ($i = 0; $i < 100000; ++$i) {
    $array[$i] = 0;
}
$array[42] = 42;
$array[420] = 420;

But what if we just skip the initialization part?

What is the STRING_TO_INT type useful for?

Standard PHP arrays are quite efficient in terms of dictionary, how does Judy arrays with STRING_TO_INT type behave in this regards? More memory efficient as well? Less CPU intensive?

Regarding the huge improvements made on PHP arrays in PHP 7, what are the Judy types that would still be relevant if the extension was made compatible with it?

Last question, how does PHP Judy arrays behave when accessing an element that is not set? I think this is also one important point of such type ;-)

Thanks in advance for your answers @orieg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant