PEP 372 -- Adding an ordered directory to collections

"Martin v. Löwis" martin at v.loewis.de
Mon Jun 16 18:24:12 EDT 2008


>     ``odict.byindex(index)``
> 
>         Index-based lookup is supported by ``byindex()`` which returns
>         the key/value pair for an index, that is, the "position" of a
>         key in the ordered dict.  0 is the first key/value pair, -1
>         the last.
> 
>         >>> d.byindex(2)
>         ('foo', 'bar')

For this API, I think it's important to make some performance
guarantees. It seems fairly difficult to make byindex O(1), and
simultaneously also make insertion/deletion better than O(n).

IOW, the PEP should somehow specify which operations are efficient,
and which ones aren't.

Regards,
Martin



More information about the Python-list mailing list