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 jimd
Recipients jimd
Date 2017-08-20.05:14:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1503206046.25.0.821679783552.issue31240@psf.upfronthosting.co.za>
In-reply-to
Content
Code such as mydict.setdefault('eggs', []) will needlessly incur the cost of instantiating a list even when 'eggs' is already a valid key in mydict.  collections.defaultdict will not do this.  detecting and automatically calling "callable" and "type" objects (implicit laziness) would break cases where callables and types are used as first class values.

Add keyword argument: lazy?  Thus mydict.setdefault('eggs',list, lazy=True) would generate a new list only when necessary while the default would still be to append a reference to list (first class) objects).
History
Date User Action Args
2017-08-20 05:14:06jimdsetrecipients: + jimd
2017-08-20 05:14:06jimdsetmessageid: <1503206046.25.0.821679783552.issue31240@psf.upfronthosting.co.za>
2017-08-20 05:14:06jimdlinkissue31240 messages
2017-08-20 05:14:05jimdcreate