3 ms·
I am interested in this "It was really easy, though, because this class stored the data internally in a dictionary but the lookups on it were done by sequential
by agentbleu 19y ago
I am interested in this "It was really easy, though, because this class stored the data internally in a dictionary but the lookups on it were done by sequentially iterating through all the keys to find matching one. All I did was replacing the iteration with normal dictionary lookup."
can someone explain how to do a normal dictionary lookup?
what is that? and is there something similar in PHP?
- fendale 19y agoProbably by storing the keys in a hash table structure instead of an array.
- LogicHoleFlaw 19y agoA Python dictionary is a hashtable structure. It's kind of perverse to iterate over the keys to find the value when you can just do the hash lookup directly. A PHP array() is also a hashtable structure. The PHP equivalent of the described code would be to do a foreach() over the array rather than doing an array[key] lookup.