[Python-ideas] OrderedDict.peekitem()
Mark Lawrence
breamoreboy at yahoo.co.uk
Tue Jul 7 15:10:55 CEST 2015
On 07/07/2015 13:34, Steven D'Aprano wrote:
>
> I am unconvinced that peeking at the first and last items of a dict
> (ordered, sorted or otherwise), let alone O(1) indexed access to items,
> is a good fit for the OrderedDict API. If I were the OD maintainer, I
> would want to understand your use-case (why are you using an OD as a
> queue, instead of a list, deque, or queue?), and possibly hear two or
> three additional uses, before agreeing to add it to the API.
>
That's not what the original message said:-
<quote>
Today I was trying to use collections.OrderedDict to manage a LIFO
queue, and I was surprised to realize that OrderedDict doesn't provide a
way to look at its first or last item.
</quote>
I've no idea what the use case is for managing a LIFO queue with
anything. Only the OP can tell us what he's trying to achieve, so over
to you Kale :)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Python-ideas
mailing list