That should be faster than sending the output to the terminal. This is considerably better than 2 seconds. I think CUT will be faster that SED (but I didn't test it).
Code:
v:\> do i=1 to 5000 ( set variable_with_long_name%i=%i )
v:\> timer /q & (set | cut -d "=" -f1 > %temp\set.tmp) & timer
Timer 1 off: 18:13:39 Elapsed: 0:00:00.667
I'm working on a change to _ENVVARS so that, instead of crashing TCC when the list is too long, it will return as much as it can along with a "data incomplete" message (to stderr).