Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

dict key maximum length

170 views
Skip to first unread message

oleg.o....@gmail.com

unread,
Mar 25, 2021, 12:51:10 PM3/25/21
to
Hi, all.

How long can be dict key?

Rich

unread,
Mar 25, 2021, 1:28:27 PM3/25/21
to
oleg.o....@gmail.com <oleg.o....@gmail.com> wrote:
> Hi, all.
>
> How long can be dict key?

Test it yourself:

$ rlwrap tclsh
% dict set testlength [string repeat A [expr {2**31-1}]] Z ; list
% string length [dict keys $testlength]
2147483647

oleg.o....@gmail.com

unread,
Mar 26, 2021, 3:13:10 AM3/26/21
to
четверг, 25 марта 2021 г. в 20:28:27 UTC+3, Rich:
Thanks!

Donal K. Fellows

unread,
Mar 30, 2021, 11:38:35 AM3/30/21
to
On Thursday, 25 March 2021 at 16:51:10 UTC, oleg.o....@gmail.com wrote:
> How long can be dict key?

Dict keys can be any Tcl value; the string representation will be used as the actual value for computing the hash code. It's probably a good idea to keep them comparatively short (kilobytes, not megabytes) for performance reasons, but it isn't critical. There's no need to feel that the values (i.e., what they keys map to) are restricted at all. You might hit overall memory limits if you compute the string representation of a very big dictionary; Tcl 8.* has limits there (in the low level API of its memory allocators). If dealing with very large amounts of data, using a database is probably a good plan.

oleg.o....@gmail.com

unread,
May 18, 2021, 3:16:28 AM5/18/21
to
Thanks!
0 new messages