This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jimjjewett
Recipients
Date 2006-02-23.01:03:47
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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."
History
Date User Action Args
2007-08-23 15:45:50adminlinkissue1433928 messages
2007-08-23 15:45:50admincreate