File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -197,3 +197,24 @@ sizes and access patterns, the user may be able to provide useful hints.
197197 cache locality, and a simplified search routine. It also eliminates
198198 the need to test for dummy entries on each probe. The preconditions
199199 for this strategy arise in symbol tables and in the builtin dictionary.
200+
201+
202+ Readonly Dictionaries
203+ ---------------------
204+ Some dictionary use cases pass through a build stage and then move to a
205+ more heavily exercised lookup stage with no further changes to the
206+ dictionary.
207+
208+ An idea that emerged on python-dev is to be able to convert a dictionary
209+ to a read-only state. This can help prevent programming errors and also
210+ provide knowledge that can be exploited for lookup optimization.
211+
212+ The dictionary can be immediately rebuilt (eliminating dummy entries),
213+ resized (to an appropriate level of sparseness), and the keys can be
214+ jostled (to minimize collisions). The lookdict() routine can then
215+ eliminate the test for dummy entries (saving about 1/4 of the time
216+ spend in the collision resolution loop).
217+
218+ An additional possibility is to insert links into the empty spaces
219+ so that dictionary iteration can proceed in len(d) steps instead of
220+ (mp->mask + 1) steps.
You can’t perform that action at this time.
0 commit comments