On Fri, Dec 20, 2019 at 4:15 PM Wes Turner <[email protected]> wrote: > > How slow and space-inefficient would it be to just implement the set methods > on top of dict?
Speed: Dict doesn't cache the position of the first item. Calling next(iter(D)) repeatedly is O(N) in worst case. Space: It waste 8bytes per member. > > Do dicts lose insertion order when a key is deleted? AFAIU, OrderedDict do > not lose insertion order on delete. Dict keeps insertion order after deletion too. >Would this limit the utility of an ordered set as a queue? What set methods >does a queue need to have? I want O(1) D.popleft(). (The name is borrowed from deque. popfirst() would be better maybe). -- Inada Naoki <[email protected]> _______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/T4DT5P7CZE7A4J6XNOT6QGC5UDS4INTR/ Code of Conduct: http://python.org/psf/codeofconduct/
