Article View: comp.lang.tcl
Article #128Speed and Memory with upvar
From: meshparts
Date: Thu, 19 Nov 2026 15:42
Date: Thu, 19 Nov 2026 15:42
23 lines
1419 bytes
1419 bytes
I'm thinking about the differences between two methods of passing a list
to a procedure:
First one is classical:
proc myproc1 {l} {}
set l [list 1 2 3]
myproc1 $l
Second one uses upvar:
proc myproc2 {lname} {upvar $lname l}
set l [list 1 2 3]
myproc2 l
My tests show that first one is faster than second one. At least for
lists of thousends of elements.
Does the second method also has advantages regarding the memory
consuption or are the two methods identical from this point of view?
Thanks
Alex
Technical Details
Message-ID:
<11dn5cd$4ibt$1@tota-refugium.de>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.tota-refugium.de!.POSTED!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.tota-refugium.de!.POSTED!not-for-mail From: meshparts <alexandru.dadalau@meshparts.de> Newsgroups: comp.lang.tcl Subject: Speed and Memory with upvar Date: Thu, 19 Nov 2026 16:42:03 +0100 Message-ID: <11dn5cd$4ibt$1@tota-refugium.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 19 Nov 2026 15:42:05 -0000 (UTC) Injection-Info: tota-refugium.de; logging-data="149885"; mail-complaints-to="abuse@news.tota-refugium.de" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:olRtgdmO/aD2T5YN3wPHCT5ILOQ= X-User-ID: eJwFwQkBwDAIA0BLrBAeOaMB/xJ6B/XPb5jDDYvNMh6bQ/3BGaGzeHVCexbDCnT2hqSIdNoDMD4Rnw==