Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2020-09-23
18:54 • Closed ticket [b9ecf3ce98]: uplevel $list, uplevel 1 $list and generation of... artifact: b5591bfa87 user: pooryorick
2020-09-20
13:47 • Ticket [b9ecf3ce98]: 3 changes artifact: 114b3a249c user: pooryorick
2020-09-19
17:28 • Ticket [9eac2d8a8d] uplevel: level sniffing for single arg, default-level case (... artifact: 46fed0a6ac user: pooryorick
16:32 • Ticket [b9ecf3ce98] uplevel $list, uplevel 1 $list and generation of string ... artifact: c9f3dc345a user: dgp
15:08 • Ticket [1017884fff] make 'level' arg to uplevel/upvar mandatory stat... artifact: 57c85fd351 user: pooryorick
14:34 • Ticket [b9ecf3ce98] uplevel $list, uplevel 1 $list and generation of string ... artifact: 191070729b user: pooryorick
14:33
Fix for [b9ecf3ce98], [uplevel] unnecessarily generates string representation. check-in: d67c23f6d1 user: pooryorick tags: core-8-6-branch
14:15 • Ticket [b9ecf3ce98] uplevel $list, uplevel 1 $list and generation of string ... artifact: bf67df259c user: pooryorick
14:10
Fix for [b9ecf3ce98], [uplevel] unnecessarily generates string representation. check-in: 45569c7084 user: pooryorick tags: core-8-branch
2016-05-05
04:11 • New ticket [b9ecf3ce98] uplevel $list, uplevel 1 $list and generation of str... artifact: 88ae61c117 user: pooryorick

[uplevel $list], [uplevel 1 $list] and generation of string representations

Closed / Fixedb9ecf3ce9801c480620f83b34110f808bd11affbCreated 11 years agoUpdated 6 years ago
Descriptionwiki2016-05-05 04:11:20
The following script causes a string representation to be generated for each item in the list passed to 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.

Referenced by3
  • 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:27
  • d67c23f6d1Fix for [b9ecf3ce98], [uplevel] unnecessarily generates string representation. check-in2020-09-19 14:33:24
  • 45569c7084Fix for [b9ecf3ce98], [uplevel] unnecessarily generates string representation. check-in2020-09-19 14:10:44
pooryorickwiki2020-09-19 14:15:40

Fixed in [45569c7084346632] for core-8-barnch.

pooryorickwiki2020-09-19 14:34:37

Fixed in [d67c23f6d1422fcf] for core-8-6-branch.

dgpplain2020-09-19 16:32:01
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.
pooryorickwiki2020-09-20 13:47:58

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.

pooryorick Closed ticket [b9ecf3ce98]. [History diff]2020-09-23 18:54:11
Log in (anonymous is fine) to add a comment.