<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 2, 2013 at 6:01 AM, Serhiy Storchaka <span dir="ltr"><<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I propose to add new standard collection types: IdentityDict and IdentitySet. They are almost same as ordinal dict and set, but uses identity check instead of equality check (and id() or hash(id()) as a hash). They will be useful for pickling, for implementing __sizeof__() for compound types, and for other graph algorithms.<br>


<br>
Of course, they can be implemented using ordinal dicts:<br>
<br>
    IdentityDict: key -> value as a dict: id(key) -> (key, value)<br>
    IdentitySet as a dict: id(value) -> value<br>
<br>
However implementing them directly in the core has advantages, it consumes less memory and time, and more comfortable for use from C. IdentityDict and IdentitySet implementations will share almost all code with implementations of ordinal dict and set, only lookup function and metainformation will be different. However dict and set already use a lookup function overloading.<br>


<br></blockquote><div><br></div><div>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.<br>

<br>Eli<br> <br></div></div><br></div></div>