[Python-ideas] Identity dicts and sets
Mike Meyer
mwm at mired.org
Wed Jan 2 21:37:12 CET 2013
On Wed, Jan 2, 2013 at 2:34 PM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> середа 02 січень 2013 21:43:47 Eli Bendersky ви написали:
>> I agree that the data structures may be useful, but is there no way to some
>> allow the customization of existing data structures instead, without losing
>> performance? It's a shame to have another kind of dict just for this
>> purpose.
>> What interface for the customization is possible? Obviously, a dict
> constructor can't have a special keyword argument.
How about a set_key method? It takes a single callable as an argument.
You'd get your behavior with dict.set_key(id). If called when the dict
is non-empty, it should throw an exception.
<mike
More information about the Python-ideas
mailing list