Tcl Source Code

Hex Artifact Content
Login

Artifact 3b7a57eb57f407bbb71ebaa61f8cadea76590f0004e0246f5e6f3bcc672b8b32:

Ticket change [3b7a57eb57] - Ticket [28cc67a606a7ab77|28cc67a606] <i>array set from dict: set values multi times on the same array is slower with Tcl9.0.</i> status still Open with 3 other changes by sebres 2024-04-16 17:22:57.
0000: 44 20 32 30 32 34 2d 30 34 2d 31 36 54 31 37 3a  D 2024-04-16T17:
0010: 32 32 3a 35 37 2e 39 32 36 0a 4a 20 69 63 6f 6d  22:57.926.J icom
0020: 6d 65 6e 74 20 54 68 69 73 5c 73 64 65 66 69 6e  ment This\sdefin
0030: 69 74 65 6c 79 5c 73 62 65 6c 6f 6e 67 73 5c 73  itely\sbelongs\s
0040: 74 6f 5c 73 61 62 73 74 72 61 63 74 2d 6c 69 73  to\sabstract-lis
0050: 74 73 5c 73 69 6d 70 6c 65 6d 65 6e 74 61 74 69  ts\simplementati
0060: 6f 6e 5c 73 6f 66 5c 73 39 2e 30 5c 73 61 6e 64  on\sof\s9.0\sand
0070: 5c 73 61 6c 74 68 6f 75 67 68 5c 73 69 74 5c 73  \salthough\sit\s
0080: 77 61 73 5c 73 73 75 70 70 6f 73 65 64 5c 73 74  was\ssupposed\st
0090: 6f 5c 73 62 65 5c 73 62 65 74 74 65 72 5c 73 28  o\sbe\sbetter\s(
00a0: 61 76 6f 69 64 5c 73 73 68 69 6d 6d 65 72 5c 73  avoid\sshimmer\s
00b0: 6f 66 5c 73 64 69 63 74 5c 73 74 6f 5c 73 6c 69  of\sdict\sto\sli
00c0: 73 74 29 2c 5c 73 69 6e 5c 73 74 68 65 5c 73 72  st),\sin\sthe\sr
00d0: 65 61 6c 69 74 79 5c 73 69 74 5c 73 69 73 5c 73  eality\sit\sis\s
00e0: 72 61 74 68 65 72 5c 73 77 6f 72 73 65 5c 73 6e  rather\sworse\sn
00f0: 6f 77 3a 5c 72 5c 6e 5c 72 5c 6e 2d 5c 73 6c 69  ow:\r\n\r\n-\sli
0100: 73 74 5c 73 66 61 63 69 6c 69 74 69 65 73 5c 73  st\sfacilities\s
0110: 70 72 65 76 69 6f 75 73 6c 79 5c 73 68 61 6e 64  previously\shand
0120: 6c 65 73 5c 73 70 75 72 65 2d 64 69 63 74 73 5c  les\spure-dicts\
0130: 73 62 65 74 74 65 72 5c 73 28 65 76 65 6e 5c 73  sbetter\s(even\s
0140: 69 66 5c 73 69 74 5c 73 73 68 69 6d 6d 65 72 65  if\sit\sshimmere
0150: 64 5c 73 73 6f 6d 65 74 69 6d 65 73 5c 73 62 65  d\ssometimes\sbe
0160: 74 77 65 65 6e 5c 73 6c 69 73 74 2f 64 69 63 74  tween\slist/dict
0170: 29 2e 5c 72 5c 6e 2d 5c 73 62 79 5c 73 72 65 74  ).\r\n-\sby\sret
0180: 72 69 65 76 69 6e 67 5c 73 6f 66 5c 73 6c 65 6e  rieving\sof\slen
0190: 67 74 68 5c 73 28 44 69 63 74 41 73 4c 69 73 74  gth\s(DictAsList
01a0: 4c 65 6e 67 74 68 29 5c 73 6e 6f 77 5c 73 69 74  Length)\snow\sit
01b0: 5c 73 61 6c 77 61 79 73 5c 73 6f 62 74 61 69 6e  \salways\sobtain
01c0: 5c 73 73 74 72 69 6e 67 5c 73 72 65 70 72 65 73  \sstring\srepres
01d0: 65 6e 74 61 74 69 6f 6e 5c 73 6f 66 5c 73 64 69  entation\sof\sdi
01e0: 63 74 5c 73 28 61 6c 73 6f 5c 73 66 6f 72 5c 73  ct\s(also\sfor\s
01f0: 70 75 72 65 2d 64 69 63 74 5c 73 6f 62 6a 65 63  pure-dict\sobjec
0200: 74 29 2c 5c 73 77 68 61 74 3a 5c 72 5c 6e 5c 73  t),\swhat:\r\n\s
0210: 5c 73 5c 73 2a 5c 73 6d 61 79 5c 73 62 65 5c 73  \s\s*\smay\sbe\s
0220: 73 6c 6f 77 5c 73 61 6e 64 5c 73 5c 72 5c 6e 5c  slow\sand\s\r\n\
0230: 73 5c 73 5c 73 2a 5c 73 63 61 75 73 65 73 5c 73  s\s\s*\scauses\s
0240: 74 68 61 74 5c 73 64 69 63 74 5c 73 6f 62 6a 65  that\sdict\sobje
0250: 63 74 5c 73 69 73 5c 73 6e 6f 74 5c 73 70 75 72  ct\sis\snot\spur
0260: 65 5c 73 61 6e 79 6d 6f 72 65 5c 73 28 62 61 73  e\sanymore\s(bas
0270: 69 63 61 6c 6c 79 5c 73 77 65 5c 73 6e 65 65 64  ically\swe\sneed
0280: 5c 73 61 5c 73 66 6c 61 67 5c 73 66 6f 72 5c 73  \sa\sflag\sfor\s
0290: 74 68 61 74 2c 5c 73 74 6f 5c 73 6d 61 72 6b 5c  that,\sto\smark\
02a0: 73 70 75 72 65 2d 64 69 63 74 73 5c 73 69 6e 64  spure-dicts\sind
02b0: 65 70 65 6e 64 65 6e 74 6c 79 5c 73 74 6f 5c 73  ependently\sto\s
02c0: 65 78 69 73 74 65 6e 63 65 5c 73 6f 66 5c 73 69  existence\sof\si
02d0: 74 73 5c 73 73 74 72 69 6e 67 5c 73 72 65 70 72  ts\sstring\srepr
02e0: 65 73 65 6e 74 61 74 69 6f 6e 29 5c 72 5c 6e 2d  esentation)\r\n-
02f0: 5c 73 44 69 63 74 41 73 4c 69 73 74 4c 65 6e 67  \sDictAsListLeng
0300: 74 68 5c 73 28 62 75 74 5c 73 62 61 73 69 63 61  th\s(but\sbasica
0310: 6c 6c 79 5c 73 4f 62 6a 54 79 70 65 3a 3a 4c 65  lly\sObjType::Le
0320: 6e 67 74 68 50 72 6f 63 29 5c 73 63 61 6e 6e 6f  ngthProc)\scanno
0330: 74 5c 73 68 61 6e 64 6c 65 5c 73 65 72 72 6f 72  t\shandle\serror
0340: 73 2c 5c 73 77 68 61 74 5c 73 6d 61 79 5c 73 62  s,\swhat\smay\sb
0350: 65 5c 73 6e 6f 74 5c 73 73 6f 5c 73 67 6f 6f 64  e\snot\sso\sgood
0360: 5c 73 66 6f 72 5c 73 61 5c 73 70 6f 73 73 69 62  \sfor\sa\spossib
0370: 6c 65 5c 73 66 61 6c 6c 62 61 63 6b 5c 73 28 69  le\sfallback\s(i
0380: 66 5c 73 64 69 63 74 5c 73 69 73 5c 73 6e 6f 74  f\sdict\sis\snot
0390: 5c 73 70 75 72 65 5c 73 64 69 63 74 29 3b 5c 72  \spure\sdict);\r
03a0: 5c 6e 2d 5c 73 72 65 74 72 69 65 76 69 6e 67 5c  \n-\sretrieving\
03b0: 73 6f 66 5c 73 69 6e 64 65 78 5c 73 28 69 66 5c  sof\sindex\s(if\
03c0: 73 6f 6e 65 5c 73 77 6f 75 6c 64 5c 73 69 6d 70  sone\swould\simp
03d0: 6c 65 6d 65 6e 74 5c 73 69 74 5c 73 66 6f 72 5c  lement\sit\sfor\
03e0: 73 64 69 63 74 29 2c 5c 73 65 2e 5c 73 67 2e 5c  sdict),\se.\sg.\
03f0: 73 66 6f 72 5c 73 49 4e 53 54 5f 46 4f 52 45 41  sfor\sINST_FOREA
0400: 43 48 5f 53 54 45 50 2f 49 4e 53 54 5f 46 4f 52  CH_STEP/INST_FOR
0410: 45 41 43 48 5f 53 54 41 52 54 5c 73 69 6e 73 74  EACH_START\sinst
0420: 72 75 63 74 69 6f 6e 73 2c 5c 73 69 73 5c 73 68  ructions,\sis\sh
0430: 61 72 64 6c 79 5c 73 70 6f 73 73 69 62 6c 65 2c  ardly\spossible,
0440: 5c 73 62 65 63 61 75 73 65 5c 72 5c 6e 6e 6f 72  \sbecause\r\nnor
0450: 6d 61 6c 5c 73 69 74 65 72 61 74 69 6f 6e 5c 73  mal\siteration\s
0460: 6f 76 65 72 5c 73 74 68 65 5c 73 64 69 63 74 5c  over\sthe\sdict\
0470: 73 6e 65 65 64 73 5c 73 73 6f 6d 65 5c 73 69 6e  sneeds\ssome\sin
0480: 74 65 72 69 6d 5c 73 54 63 6c 5f 44 69 63 74 53  terim\sTcl_DictS
0490: 65 61 72 63 68 5c 73 28 6f 72 5c 73 73 69 6d 69  earch\s(or\ssimi
04a0: 6c 61 72 5c 73 69 74 65 72 61 74 6f 72 5c 73 68  lar\siterator\sh
04b0: 61 6e 64 6c 65 29 2c 5c 73 61 6e 64 5c 73 77 69  andle),\sand\swi
04c0: 74 68 6f 75 74 5c 73 74 68 61 74 5c 73 77 65 27  thout\sthat\swe'
04d0: 6c 6c 5c 73 67 65 74 5c 73 4f 28 6e 21 29 5c 73  ll\sget\sO(n!)\s
04e0: 61 6b 61 5c 73 66 61 63 74 6f 72 69 61 6c 5c 73  aka\sfactorial\s
04f0: 62 69 67 2d 4f 5c 73 69 66 5c 73 69 74 27 64 5c  big-O\sif\sit'd\
0500: 73 61 6c 77 61 79 73 5c 73 73 74 61 72 74 5c 73  salways\sstart\s
0510: 66 72 6f 6d 5c 73 73 63 72 61 74 63 68 5c 73 61  from\sscratch\sa
0520: 6e 64 5c 73 73 74 6f 70 5c 73 61 74 5c 73 69 6e  nd\sstop\sat\sin
0530: 64 65 78 2e 5c 72 5c 6e 2d 5c 73 4f 62 6a 54 79  dex.\r\n-\sObjTy
0540: 70 65 3a 3a 47 65 74 45 6c 65 6d 65 6e 74 73 5c  pe::GetElements\
0550: 73 6d 61 79 5c 73 62 65 5c 73 74 6f 6f 5c 73 68  smay\sbe\stoo\sh
0560: 61 72 64 5c 73 28 66 6f 72 5c 73 6c 61 72 67 65  ard\s(for\slarge
0570: 5c 73 64 69 63 74 73 29 5c 73 61 6e 64 5c 73 69  \sdicts)\sand\si
0580: 74 5c 73 69 73 5c 73 75 6e 75 73 65 64 2c 5c 73  t\sis\sunused,\s
0590: 61 6e 64 5c 73 72 69 67 68 74 6c 79 5c 73 73 6f  and\srightly\sso
05a0: 2c 5c 73 66 6f 72 5c 73 49 4e 53 54 5f 46 4f 52  ,\sfor\sINST_FOR
05b0: 45 41 43 48 5f 53 54 45 50 2f 49 4e 53 54 5f 46  EACH_STEP/INST_F
05c0: 4f 52 45 41 43 48 5f 46 49 52 53 54 5c 73 69 6e  OREACH_FIRST\sin
05d0: 73 74 72 75 63 74 69 6f 6e 73 2e 5c 72 5c 6e 2d  structions.\r\n-
05e0: 5c 73 74 68 65 72 65 5c 73 69 73 5c 73 6e 6f 5c  \sthere\sis\sno\
05f0: 73 4f 62 6a 54 79 70 65 3a 3a 49 74 65 72 61 74  sObjType::Iterat
0600: 65 5c 73 66 61 63 69 6c 69 74 79 2e 5c 72 5c 6e  e\sfacility.\r\n
0610: 5c 72 5c 6e 41 6c 6c 5c 73 74 68 61 74 5c 73 6d  \r\nAll\sthat\sm
0620: 61 6b 65 73 5c 73 64 69 66 66 69 63 75 6c 74 5c  akes\sdifficult\
0630: 73 74 6f 5c 73 69 6d 70 6c 65 6d 65 6e 74 5c 73  sto\simplement\s
0640: 69 74 5c 73 77 69 74 68 5c 73 72 65 61 73 6f 6e  it\swith\sreason
0650: 61 62 6c 65 5c 73 70 65 72 66 6f 72 6d 61 6e 63  able\sperformanc
0660: 65 5c 73 66 6f 72 5c 73 61 6c 6c 5c 73 63 6f 72  e\sfor\sall\scor
0670: 6e 65 72 5c 73 63 61 73 65 73 2e 5c 73 48 6f 77  ner\scases.\sHow
0680: 65 76 65 72 5c 73 49 27 6c 6c 5c 73 74 61 6b 65  ever\sI'll\stake
0690: 5c 73 61 5c 73 63 6c 6f 73 65 72 5c 73 6c 6f 6f  \sa\scloser\sloo
06a0: 6b 5c 73 74 6f 5c 73 74 68 69 73 5c 73 6c 61 74  k\sto\sthis\slat
06b0: 65 72 2e 0a 4a 20 6c 6f 67 69 6e 20 73 65 62 72  er..J login sebr
06c0: 65 73 0a 4a 20 6d 69 6d 65 74 79 70 65 20 74 65  es.J mimetype te
06d0: 78 74 2f 78 2d 6d 61 72 6b 64 6f 77 6e 0a 4b 20  xt/x-markdown.K 
06e0: 32 38 63 63 36 37 61 36 30 36 61 37 61 62 37 37  28cc67a606a7ab77
06f0: 31 61 66 34 63 37 62 35 34 32 62 33 34 65 63 31  1af4c7b542b34ec1
0700: 61 33 37 37 65 64 63 37 0a 55 20 73 65 62 72 65  a377edc7.U sebre
0710: 73 0a 5a 20 38 63 39 62 63 66 36 61 31 35 34 66  s.Z 8c9bcf6a154f
0720: 61 63 39 66 63 32 63 39 36 34 66 62 36 37 35 65  ac9fc2c964fb675e
0730: 30 38 32 62 0a                                   082b.