Re: Dict vs array performance



On Aug 30, 11:57 am, Rich <google-em...@xxxxxxxxx> wrote:
Is there a reason why this difference in speed should exist?


This is because [info exists] is bytecode-compiled to be about as
efficient as an array variable read[*], and [dict exists] is not (the
variable holding the dictionary has to be read, then the [dict]
command invoked - which dispatches to the [dict exists] implementation
- then a hash lookup performed).

Donal.
[* Minimum one hash table lookup, perhaps more depending on caching. ]
.



Relevant Pages

  • Re: tracking collection modification
    ... For the purposes of caching I need to be able to tell if a given ... dict / list / set has been modified. ... concurrent access by various clients - as client connection has to keep ...
    (comp.lang.python)
  • Re: Dict sharing vs. duplication
    ... Strictly no. You're naming the variable holding the dict, ... % dict keys $a ... a dict is not a nested series of similar ...
    (comp.lang.tcl)
  • Re: tracking collection modification
    ... For the purposes of caching I need to be able to tell if a given ... dict / list / set has been modified. ... subclassing them to add the modification count isn't useful. ...
    (comp.lang.python)
  • Re: tracking collection modification
    ... For the purposes of caching I need to be able to tell if a given ... dict / list / set has been modified. ... I realize I could take a copy and then compare the copy to the ...
    (comp.lang.python)