[uplevel $list], [uplevel 1 $list] and generation of string representations
uplevel, but if a level specifier is
added as the first argument to uplevel, string representations
aren't generated:
apply {{} {
uplevel [list apply {{args} {
foreach arg $args {puts [::tcl::unsupported::representation $arg]}
}} {*}[list [expr 1] [expr 2]]]
}}
The generation of string representations for items in such a list could have a significant unexpected performance/memory impact.
Ticket 1017884 is related, but this one-argument case could probably be fixed without the backward-incompatible change suggested in that ticket, since the single argument can be assumed to be the script to be evaluated.
46fed0a6acTicket [9eac2d8a8d] uplevel: level sniffing for single arg, default-level case (absolute level specifier only) status still Open with 3 other changes ticket2020-09-19 17:28:27d67c23f6d1Fix for [b9ecf3ce98], [uplevel] unnecessarily generates string representation. check-in2020-09-19 14:33:2445569c7084Fix for [b9ecf3ce98], [uplevel] unnecessarily generates string representation. check-in2020-09-19 14:10:44
Fixed in [45569c7084346632] for core-8-barnch.
Fixed in [d67c23f6d1422fcf] for core-8-6-branch.
Effect of this patch is to avoid string generation for the particular case of a pure list with no explicit level argument. Tradeoff is the shimmering generation of a list representation for values that came in with other intreps. Might mean loss of bytecode. Or fragile intreps. Or expensive ones. It's a lot easier to train coders to include the explicit level argument than to have mercurial performance dances like this.
This tradeoff has been mitigated by only checking list length if there is no string representation. This covers the bytecode case, which is probably the most important one. See [76da711d7172c54a]. It could be further mitigated by checking for a list or dict intrep first, and then ultimately by writing the TIP that would make the whole check unnecessary.