On Wed, Apr 29, 2020 at 8:02 AM Ram Rachum <r...@rachum.com> wrote: > Thanks everybody for your answers, and especially Ricky for finding this > note. >
which seems to indicate that if one were to implement this code more efficiently, it would be considered for inclusion. I will note that for the most part, the Python specs are for the API, and do not guarantee particular performance characteristics. Dicts are efficient because they need to be for reasonable performance of the entire interpreter, but it isn't part of the Mapping ABC. Is there a single instance of the SAME ABC being implemented in two ways, with different performance characteristics? I've wondered about Linked Lists for a while, but while there are many versions on PyPi, I can't find one that seems to be mature and maintained. Which seems to indicate that there isn't much demand for them. -CHB > On Wed, Apr 29, 2020 at 2:20 PM Ricky Teachey <ri...@teachey.org> wrote: > >> I was playing around with deque today, and there were a couple of >>> operations I wanted to do, that can't really be done efficiently with deque >>> because of its implementation. >>> >>> ... >>> >>> What do you think about adding [O(1) insert and remove] this to `deque`? >>> >> >> _collectionsmodule.c has this note, so it sounds like this is intended to >> be a possibility if there is enough interest: >> >> /* insert(), remove(), and delitem() are implemented in terms of rotate() >>> for simplicity and reasonable performance near the end points. If for some >>> reason these methods become popular, it is not hard to re-implement this >>> using direct data movement (similar to the code used in list slice >>> assignments) and achieve a performance boost (by moving each pointer only >>> once instead of twice). */ >> >> >> >> https://github.com/python/cpython/blob/d16a1520c2b22c3cbde7547937ba283db3e88ff5/Modules/_collectionsmodule.c#L952-L958 >> >> >> >> --- >> Ricky. >> >> "I've never met a Kentucky man who wasn't either thinking about going >> home or actually going home." - Happy Chandler >> > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/JUOQ6DASMKMV52FKIQYAQQ4MJLYBK4LA/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/TS2WR6WVXWLHHY63FWWJA43GHIZORDAI/ Code of Conduct: http://python.org/psf/codeofconduct/