Message49524
Logged In: YES
user_id=764593
Two use cases for overriding on_missing, but not needing a
factory:
(1) Stacked configuration objects. If it isn't in the
first, check the second, etc. Override on_missing with the
__getitem__ of the next configuration object. (Or perhaps a
for loop over several fallbacks -- but do it in the
dictionary, instead of at every lookup site.)
(2) Caching. One of the problems with setdefault is that
it always computes the default, which may be expensive.
Note that in both of these cases, the conceptual model is
not "all new entries get the same initial value", but rather
"A normal dictionary, which just happens to be so expensive
to create that I don't want to prepopulate."
|
|
Date |
User |
Action |
Args |
2007-08-23 15:45:50 | admin | link | issue1433928 messages |
2007-08-23 15:45:50 | admin | create | |
|