Re: Access times of an array
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Access times of an array

From: Ben C <spamspam@spam.eggs>
Date: Mon Mar 13 2006 - 23:06:23 CET

On 2006-03-13, randyjheeta@gmail.com <randyjheeta@gmail.com> wrote:
> My script is growing quite large, and I am considering grouping my
> global variables into an array, similar to:
>
> array set {
> Orange 1
> Apple 5
> Banana 6
> }
>
> instead of:
>
> global Orange
> global Apples
> global Banana
>
>
> Will I be at a serious speed disadvantage if I do this?

I wouldn't have thought so, since Tcl arrays are dictionaries. I mean,
if you were thinking that to find the value of Banana the interpreter
would have to start searching from the top, then I don't think it does.
Instead it surely looks it up in some quite well optimized data
structure like a hash table.
Received on Sun Apr 30 02:31:17 2006