Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Over the shoulder supervision is more a need of the manager than the programming task.


devel / comp.lang.tcl / Safe handling of lists

SubjectAuthor
* Safe handling of listsclt.to.davebr
+* Safe handling of listsRich
|`* Safe handling of listset99
| +- Safe handling of listsLuc
| `* Safe handling of listsRich
|  `* Safe handling of listsLuc
|   +- Safe handling of listset99
|   `- Safe handling of listsRich
+- Safe handling of listsPeter Dean
`* Safe handling of listsPeter Dean
 +* Safe handling of listset99
 |`- Safe handling of listsPeter Dean
 +- Safe handling of listsLuc
 `* Safe handling of listsRich
  `- Safe handling of listsPeter Dean

1
Safe handling of lists

<4431701284844@dlp>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12879&group=comp.lang.tcl#12879

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: clt.to.davebr@dfgh.net
Newsgroups: comp.lang.tcl
Subject: Safe handling of lists
Date: Wed, 29 Nov 23 19:07:24 GMT
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <4431701284844@dlp>
Injection-Info: dont-email.me; posting-host="f44ff9c2793715596881771caca57821";
logging-data="999582"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//3dnI1pxBXMHbjk1eHXw1"
Cancel-Lock: sha1:nB6mjHtg4IyMflAMnXSxF0SsjhI=
 by: clt.to.davebr@dfgh.net - Wed, 29 Nov 2023 19:07 UTC

>> proc p.wc {content} {
>> set wordcount 0
>> regsub -all {[\s]+} [string trim $content] { } content
>> set wordcount [llength [split $content { }]]
>> return $wordcount
>> }
>
>You can reduce the above to this:
>
>proc p.wc {content} {
> return [llength [regsub -all -inline {\S+} $content]]
>}
>

Why not use Christian's suggestion from above?

proc p.wc {content} {
regex -all {\S+} $content
}

or just use the command without the proc wrapper

Dave B

Re: Safe handling of lists

<uk80g9$uq6o$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12880&group=comp.lang.tcl#12880

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Wed, 29 Nov 2023 18:39:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <uk80g9$uq6o$1@dont-email.me>
References: <4431701284844@dlp>
Injection-Date: Wed, 29 Nov 2023 18:39:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="20212c49318bf064762e9e5d917085c4";
logging-data="1009880"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hd4U5LhOrKmcJaHLMBzuK"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:9JIQF4jv+1BQ3EKlQaWwtYBjpwo=
 by: Rich - Wed, 29 Nov 2023 18:39 UTC

clt.to.davebr@dfgh.net wrote:
>
>>> proc p.wc {content} {
>>> set wordcount 0
>>> regsub -all {[\s]+} [string trim $content] { } content
>>> set wordcount [llength [split $content { }]]
>>> return $wordcount
>>> }
>>
>>You can reduce the above to this:
>>
>>proc p.wc {content} {
>> return [llength [regsub -all -inline {\S+} $content]]
>>}
>>
>
> Why not use Christian's suggestion from above?
>
> proc p.wc {content} {
> regex -all {\S+} $content
> }

Without -inline back a boolean from regex, and Luc wants a word count.

With -inline you get the matches as a list, and the llength is to
produce a 'count' (length of list) from the raw matches.

> or just use the command without the proc wrapper

Valid ask, but in my case I just created the minimal change to Luc's
example code, without going into other details.

Re: Safe handling of lists

<uk84sa$vf4r$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12881&group=comp.lang.tcl#12881

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: p.dean@gmx.com (Peter Dean)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Wed, 29 Nov 2023 19:53:46 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Sender: <peter@arch1701.localdomain>
Message-ID: <uk84sa$vf4r$1@dont-email.me>
References: <4431701284844@dlp>
Injection-Date: Wed, 29 Nov 2023 19:53:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8dec35c0e4543e0d8537605e1e3506b3";
logging-data="1031323"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Oo6sHWud3E1cf66zU2wt+"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.63-1-lts (x86_64))
Cancel-Lock: sha1:RE+Tg94VGy7ljlkBIb+93Jvlmmc=
 by: Peter Dean - Wed, 29 Nov 2023 19:53 UTC

clt.to.davebr@dfgh.net wrote:
>
>>> proc p.wc {content} {
>>> set wordcount 0
>>> regsub -all {[\s]+} [string trim $content] { } content
>>> set wordcount [llength [split $content { }]]
>>> return $wordcount
>>> }
>>
>>You can reduce the above to this:
>>
>>proc p.wc {content} {
>> return [llength [regsub -all -inline {\S+} $content]]
>>}
>>
>
> Why not use Christian's suggestion from above?
>
> proc p.wc {content} {
> regex -all {\S+} $content
> }
>
> or just use the command without the proc wrapper
>
> Dave B
>

+1

Christian's comment forced me to
man n regexp

pd

Re: Safe handling of lists

<uk85bp$vf12$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12882&group=comp.lang.tcl#12882

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Wed, 29 Nov 2023 12:02:01 -0800
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <uk85bp$vf12$1@dont-email.me>
References: <4431701284844@dlp> <uk80g9$uq6o$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 29 Nov 2023 20:02:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7b6b603e2ea13295a0842856719e340f";
logging-data="1031202"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RWX7dyGlgyQiB3eOMXH2M"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:bcEDkFLsrdLcJQWqB4DMFLegrLg=
In-Reply-To: <uk80g9$uq6o$1@dont-email.me>
Content-Language: en-US
 by: et99 - Wed, 29 Nov 2023 20:02 UTC

On 11/29/2023 10:39 AM, Rich wrote:
> clt.to.davebr@dfgh.net wrote:
>>
>>>> proc p.wc {content} {
>>>> set wordcount 0
>>>> regsub -all {[\s]+} [string trim $content] { } content
>>>> set wordcount [llength [split $content { }]]
>>>> return $wordcount
>>>> }
>>>
>>> You can reduce the above to this:
>>>
>>> proc p.wc {content} {
>>> return [llength [regsub -all -inline {\S+} $content]]
>>> }
>>>
>>
>> Why not use Christian's suggestion from above?
>>
>> proc p.wc {content} {
>> regex -all {\S+} $content
>> }
>
> Without -inline back a boolean from regex, and Luc wants a word count.
>
> With -inline you get the matches as a list, and the llength is to
> produce a 'count' (length of list) from the raw matches.
>
>> or just use the command without the proc wrapper
>
> Valid ask, but in my case I just created the minimal change to Luc's
> example code, without going into other details.

Actually, for regexp with -all it returns the count of matches as desired.

So, based on the above posts, here's a very compact form using a Thread when a full update is desired, say after a multi-line change, e.g. cut or paste.:

set ::tid [thread::create] ;# with no script it just does a thread::wait

Then when you want a clean full update, you can queue this

tsv::set text x [$::text get 1.0 end]
unset -nocomplain ::count_from_thread
thread::send -async $::tid {regexp -all {\S+} [tsv::get text x]} count_from_thread

Or... I suppose you could even just set ::WholeBufferWC

tsv::set text x [$::text get 1.0 end]
thread::send -async $::tid {regexp -all {\S+} [tsv::get text x]} ::WholeBufferWC

The only reason I prefer the unset method on a separate variable is to avoid a possible race condition. As long as you don't re-enter the event loop inside your callback for a text widget change, I don't think that can happen.

Re: Safe handling of lists

<20231129171358.0a08c3ab@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12883&group=comp.lang.tcl#12883

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Wed, 29 Nov 2023 17:13:58 -0300
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <20231129171358.0a08c3ab@lud1.home>
References: <4431701284844@dlp>
<uk80g9$uq6o$1@dont-email.me>
<uk85bp$vf12$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="9880784e4e99c5b0efae91381a0bc5cc";
logging-data="1037565"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18AtX+m5WNsJ6oyfCRXRBaheGFBoMXf0zc="
Cancel-Lock: sha1:CD3rdd6hRDS5gB/YgwglMgG0ypU=
 by: Luc - Wed, 29 Nov 2023 20:13 UTC

On Wed, 29 Nov 2023 12:02:01 -0800, et99 wrote:

>So, based on the above posts, here's a very compact form using a Thread
>when a full update is desired, say after a multi-line change, e.g. cut or
>paste.:
**************************

Ah, yes. Multi-line changes e.g. cut or paste. My code doesn't support
any of that. I will have to think about it and find a fix.

Of course, I will look into the code you provided later.

Thank you.

--
Luc
>>

Re: Safe handling of lists

<uk8666$vm7s$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12884&group=comp.lang.tcl#12884

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Wed, 29 Nov 2023 20:16:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <uk8666$vm7s$1@dont-email.me>
References: <4431701284844@dlp> <uk80g9$uq6o$1@dont-email.me> <uk85bp$vf12$1@dont-email.me>
Injection-Date: Wed, 29 Nov 2023 20:16:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="20212c49318bf064762e9e5d917085c4";
logging-data="1038588"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184Z95AP8NIAY1ckZ9d4gBL"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:S8zj2tFp9+cu1RLHcaM+ISTYVlE=
 by: Rich - Wed, 29 Nov 2023 20:16 UTC

et99 <et99@rocketship1.me> wrote:
> On 11/29/2023 10:39 AM, Rich wrote:

>> Without -inline [back] a boolean [is returned] from regex, and Luc
>> wants a word count.
>>
>> With -inline you get the matches as a list, and the llength is to
>> produce a 'count' (length of list) from the raw matches.
>>
>>> or just use the command without the proc wrapper
>>
>> Valid ask, but in my case I just created the minimal change to Luc's
>> example code, without going into other details.
>
>
> Actually, for regexp with -all it returns the count of matches as
> desired.

Ah, learn something new every day. I had not noticed that -all returns
a count of matches. That saves creating a list only to take it's
length and free it all over again.

Re: Safe handling of lists

<20231129185122.65ebee28@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12885&group=comp.lang.tcl#12885

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Wed, 29 Nov 2023 18:51:22 -0300
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <20231129185122.65ebee28@lud1.home>
References: <4431701284844@dlp>
<uk80g9$uq6o$1@dont-email.me>
<uk85bp$vf12$1@dont-email.me>
<uk8666$vm7s$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="9880784e4e99c5b0efae91381a0bc5cc";
logging-data="1066749"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+96c5EqFY1/zMq5wnVULXWmL487zmiNSY="
Cancel-Lock: sha1:tZ5cO3eE23zpFUCGgKCnwEha4Ik=
 by: Luc - Wed, 29 Nov 2023 21:51 UTC

On Wed, 29 Nov 2023 20:16:07 -0000 (UTC), Rich wrote:

>Ah, learn something new every day. I had not noticed that -all returns
>a count of matches. That saves creating a list only to take it's
>length and free it all over again.

**************************

"That saves" is debatable. In all my attempts, regexp always seems to be
too slow for this particular task. so I'm only using it once, when the
file is opened.

I will check, but I'm skeptical.

--
Luc
>>

Re: Safe handling of lists

<uk8dv3$10t7a$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12886&group=comp.lang.tcl#12886

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: p.dean@gmx.com (Peter Dean)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Wed, 29 Nov 2023 22:28:52 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 5
Sender: <peter@arch1701.localdomain>
Message-ID: <uk8dv3$10t7a$1@dont-email.me>
References: <4431701284844@dlp>
Injection-Date: Wed, 29 Nov 2023 22:28:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8dec35c0e4543e0d8537605e1e3506b3";
logging-data="1078506"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ds1VaEGZd2zSG2P88S2g6"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.63-1-lts (x86_64))
Cancel-Lock: sha1:zwLoa6WlRqCtBM9RTfoXZjJptE8=
 by: Peter Dean - Wed, 29 Nov 2023 22:28 UTC

clt.to.davebr@dfgh.net wrote:

Off Topic

Why do we now have three separate threads going on this one issue?

Re: Safe handling of lists

<uk8er5$111ll$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12887&group=comp.lang.tcl#12887

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Wed, 29 Nov 2023 14:43:49 -0800
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uk8er5$111ll$1@dont-email.me>
References: <4431701284844@dlp> <uk8dv3$10t7a$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 29 Nov 2023 22:43:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7b6b603e2ea13295a0842856719e340f";
logging-data="1083061"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iaj4aioe4RiL3ZZdtuFS4"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:AvgOjVWNJCfD9CExkSrfGiQ62wQ=
Content-Language: en-US
In-Reply-To: <uk8dv3$10t7a$1@dont-email.me>
 by: et99 - Wed, 29 Nov 2023 22:43 UTC

On 11/29/2023 2:28 PM, Peter Dean wrote:
> clt.to.davebr@dfgh.net wrote:
>
> Off Topic
>
> Why do we now have three separate threads going on this one issue?

I too see that, but only when using Thunderbird with eternal-september. I don't know why that happens, but they all get reduced to just one in google groups.

Re: Safe handling of lists

<20231129202011.34ae5fdf@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12888&group=comp.lang.tcl#12888

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Wed, 29 Nov 2023 20:20:11 -0300
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <20231129202011.34ae5fdf@lud1.home>
References: <4431701284844@dlp>
<uk8dv3$10t7a$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="4d2c278a3f9365ec5f8f6b0c1977542a";
logging-data="1093382"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+k9YnTTehrxfwDQQPA6B3EL1Ka1gPYYok="
Cancel-Lock: sha1:np1W2R0HueFe9tgS1tLaFgXQq0E=
 by: Luc - Wed, 29 Nov 2023 23:20 UTC

On Wed, 29 Nov 2023 22:28:52 -0000 (UTC), Peter Dean wrote:

>clt.to.davebr@dfgh.net wrote:
>
>Off Topic
>
>Why do we now have three separate threads going on this one issue?
**************************

I honestly have no idea what you are talking about. I only see one.

Eternal September and Claws Mail here.

--
Luc
>>

Re: Safe handling of lists

<uk8k7h$11phj$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12889&group=comp.lang.tcl#12889

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Wed, 29 Nov 2023 16:15:43 -0800
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <uk8k7h$11phj$1@dont-email.me>
References: <4431701284844@dlp> <uk80g9$uq6o$1@dont-email.me>
<uk85bp$vf12$1@dont-email.me> <uk8666$vm7s$1@dont-email.me>
<20231129185122.65ebee28@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 30 Nov 2023 00:15:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dc245acaf868fdd4b5147db819c95333";
logging-data="1107507"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qz7bBGK41Chuiq/AyYHAH"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:btmBh4qKRej6qNQd5JK56MmTgko=
Content-Language: en-US
In-Reply-To: <20231129185122.65ebee28@lud1.home>
 by: et99 - Thu, 30 Nov 2023 00:15 UTC

On 11/29/2023 1:51 PM, Luc wrote:
> On Wed, 29 Nov 2023 20:16:07 -0000 (UTC), Rich wrote:
>
>> Ah, learn something new every day. I had not noticed that -all returns
>> a count of matches. That saves creating a list only to take it's
>> length and free it all over again.
>
> **************************
>
> "That saves" is debatable. In all my attempts, regexp always seems to be
> too slow for this particular task. so I'm only using it once, when the
> file is opened.
>
> I will check, but I'm skeptical.
>
>

I think you're right. regexp/regsub are pretty costly on a very large 20mb text.

I tested a 20mb string

% set text [string repeat "abcdef abcdef abcdef abcdef abcdef abcdef abcdef abcdef abcdef abcdef\n" 290000] ; puts [string length $text]
20300000

% text .t
% .t insert end $text

Now...

% timems {set foo [.t get 1.0 end]}
35.405 milliseconds per iteration
% timems {regexp -all {\S+} $foo}
1,565.588 milliseconds per iteration
% timems {llength [split $foo]}
359.005 milliseconds per iteration
% timems {regsub -all {[\s]+} [string trim $foo] { } content}
1,489.499 milliseconds per iteration

So, yes, I would only do these when you have a multi-line change or at startup.

But it's pretty quick to get the text into a thread shared variable where the second thread can access it. And then running the regex/regsub etc. there shouldn't harm the responsiveness of the text widget.

% package require Thread
2.8.4
% timems {tsv::set text x [.t get 1.0 end]}
42.386 milliseconds per iteration

fyi:

proc timems {args} {
set result [uplevel 1 time $args]
set number [format %.3f [expr {( [lindex $result 0] / 1000. )}]]
set number [regsub -all {\d(?=(\d{3})+($|\.))} $number {\0,}]
return "[format %12s $number ] milliseconds [lrange $result 2 end]"
}

Re: Safe handling of lists

<uk8ljk$11s01$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12890&group=comp.lang.tcl#12890

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: p.dean@gmx.com (Peter Dean)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Thu, 30 Nov 2023 00:39:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 71
Sender: <peter@flo.localdomain>
Message-ID: <uk8ljk$11s01$1@dont-email.me>
References: <4431701284844@dlp> <uk8dv3$10t7a$1@dont-email.me> <uk8er5$111ll$1@dont-email.me>
Injection-Date: Thu, 30 Nov 2023 00:39:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d1a8ad8d19f594e6814f917a3fa5556b";
logging-data="1110017"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WRVt3GRjvr1+aS0U+oicC"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.64-1-lts (x86_64))
Cancel-Lock: sha1:oUZyC7WRsKZ7hR0mcx17Bxy0r2A=
 by: Peter Dean - Thu, 30 Nov 2023 00:39 UTC

et99 <et99@rocketship1.me> wrote:
> On 11/29/2023 2:28 PM, Peter Dean wrote:
>> clt.to.davebr@dfgh.net wrote:
>>
>> Off Topic
>>
>> Why do we now have three separate threads going on this one issue?
>
> I too see that, but only when using Thunderbird with eternal-september. I don't know why that happens, but they all get reduced to just one in google groups.
>
>

I see it on thunderbird and tin. The problem is apparent in the headers.

Here's the header from the first message in this thread

Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: clt.to.davebr@dfgh.net
Newsgroups: comp.lang.tcl
Subject: Safe handling of lists
Date: Wed, 29 Nov 23 19:07:24 GMT
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <4431701284844@dlp>
Injection-Info: dont-email.me; posting-host="f44ff9c2793715596881771caca57821";
\011logging-data="999582"; mail-complaints-to="abuse@eternal-september.org";\011posting-account="U2FsdGVkX1
//3dnI1pxBXMHbjk1eHXw1"
Cancel-Lock: sha1:nB6mjHtg4IyMflAMnXSxF0SsjhI=
Xref: news.eternal-september.org comp.lang.tcl:65599

and here's my followup

Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: p.dean@gmx.com (Peter Dean)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Wed, 29 Nov 2023 22:28:52 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 5
Sender: <peter@arch1701.localdomain>
Message-ID: <uk8dv3$10t7a$1@dont-email.me>
References: <4431701284844@dlp>
Injection-Date: Wed, 29 Nov 2023 22:28:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8dec35c0e4543e0d8537605e1e3506b3";
\011logging-data="1078506"; mail-complaints-to="abuse@eternal-september.org";\011posting-account="U2FsdGVkX
1+Ds1VaEGZd2zSG2P88S2g6"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.63-1-lts (x86_64))
Cancel-Lock: sha1:zwLoa6WlRqCtBM9RTfoXZjJptE8=
Xref: news.eternal-september.org comp.lang.tcl:65606

clt.to.davebr@dfgh.net wrote:

Off Topic

Why do we now have three separate threads going on this one issue?

You can see that the References: field in mine points to the Message-ID: field
in the OP. But there is no Reference: field in the OP's header. Therefore
threading can only happen on the subject line not the Reference: field as it is
meant to.

And let's not mention google groups please.

Re: Safe handling of lists

<uk8rb8$12kst$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12891&group=comp.lang.tcl#12891

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.network!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Thu, 30 Nov 2023 02:17:13 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <uk8rb8$12kst$1@dont-email.me>
References: <4431701284844@dlp> <uk80g9$uq6o$1@dont-email.me> <uk85bp$vf12$1@dont-email.me> <uk8666$vm7s$1@dont-email.me> <20231129185122.65ebee28@lud1.home>
Injection-Date: Thu, 30 Nov 2023 02:17:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d0334ebad83d57104bc1388ce65b792e";
logging-data="1135517"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lVJuWPRgIE81jWn30Swui"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:5dgC/ea2mnixjye1yF4EmHhrPIs=
 by: Rich - Thu, 30 Nov 2023 02:17 UTC

Luc <luc@sep.invalid> wrote:
> On Wed, 29 Nov 2023 20:16:07 -0000 (UTC), Rich wrote:
>
>>Ah, learn something new every day. I had not noticed that -all returns
>>a count of matches. That saves creating a list only to take it's
>>length and free it all over again.
>
> **************************
>
> "That saves" is debatable. In all my attempts, regexp always seems to be
> too slow for this particular task. so I'm only using it once, when the
> file is opened.
>
> I will check, but I'm skeptical.

You are not following what I said.

For the way I outlined:

[llength [regexp -all -inline ...]]

The regex engine has to do:

1) create a list to store the results (one memory allocation)

2) create a list element (one per match) and append it to the list
(one memory allocation per match)

3) depending upon the length of the list, possibly realloc() the
master list structure one or more times as the length grows

So for a text file with 1 million words, we have 1,000,001 memory
allocaations and 1,000,000 append to list operations (although these
are relatively fast, 1M of them do add up).

All to return that list, do nothing more with it beyond take its
length, and then throw it all away (to 1,000,001 free() operations).

Instead, leaving off -inline, the regex engine has to do:

1) create an integer to store the match count

2) perform "incr count" each time it finds a match (or, more likely,
a C level count++ operation on a C 'int' variable)

This second method has "saved" all the memory allocations to build up
the large list, and "saved" all the free() operations to destroy the
large list.

So it has "saved" doing all that work. But I said nor implied nothing
about whether using regexp to actually perform the counting operation
was faster or not.

Re: Safe handling of lists

<uk8rl3$12kst$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12892&group=comp.lang.tcl#12892

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Thu, 30 Nov 2023 02:22:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <uk8rl3$12kst$2@dont-email.me>
References: <4431701284844@dlp> <uk8dv3$10t7a$1@dont-email.me>
Injection-Date: Thu, 30 Nov 2023 02:22:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d0334ebad83d57104bc1388ce65b792e";
logging-data="1135517"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/f/Yn27UDwG15CEWNRakyS"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:lkvB/QcxrqwCgVytQaGbnin+L50=
 by: Rich - Thu, 30 Nov 2023 02:22 UTC

Peter Dean <p.dean@gmx.com> wrote:
> clt.to.davebr@dfgh.net wrote:
>
> Off Topic
>
> Why do we now have three separate threads going on this one issue?

Someone's news reader broke the References: header.

Re: Safe handling of lists

<uk8t7u$12tro$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12893&group=comp.lang.tcl#12893

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: p.dean@gmx.com (Peter Dean)
Newsgroups: comp.lang.tcl
Subject: Re: Safe handling of lists
Date: Thu, 30 Nov 2023 02:49:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Sender: <peter@flo.localdomain>
Message-ID: <uk8t7u$12tro$1@dont-email.me>
References: <4431701284844@dlp> <uk8dv3$10t7a$1@dont-email.me> <uk8rl3$12kst$2@dont-email.me>
Injection-Date: Thu, 30 Nov 2023 02:49:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d1a8ad8d19f594e6814f917a3fa5556b";
logging-data="1144696"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18tpFXF9ea68SRZ2FfPrWoh"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.64-1-lts (x86_64))
Cancel-Lock: sha1:O6ZfNHZjlJ5mW6Wn/uNAth0QMSU=
 by: Peter Dean - Thu, 30 Nov 2023 02:49 UTC

Rich <rich@example.invalid> wrote:
> Peter Dean <p.dean@gmx.com> wrote:
>> clt.to.davebr@dfgh.net wrote:
>>
>> Off Topic
>>
>> Why do we now have three separate threads going on this one issue?
>
> Someone's news reader broke the References: header.

And we've no clue about which newsreader or os because it broke that header as
well.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor