Issue36857
Created on 2019-05-08 18:11 by John Belmonte, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg341921 - (view) | Author: John Belmonte (John Belmonte) | Date: 2019-05-08 18:11 | |
because "list.pop()" use case: maintain large ordered list and efficiently remove min item list.pop() is O(1) but yields the max item. There is no efficient removal of the min item. list is by far the fastest collection to use with insort(). While deque offers O(1) popleft(), insort() performance with deque is not acceptable. Lack of descending support in bisect necessitates workarounds such as using negative-valued items, which hurts code readability and moreover assumes that values are numbers. |
|||
| msg341934 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2019-05-08 19:50 | |
Sorry, I don't think this is a worthwhile API extension. The bisect module is primarily about searching for cut points between ranges. For your use case, consider using blist or one of the many ordered collection recipes on PyPI (for example: http://www.grantjenks.com/docs/sortedcollections/ ). |
|||
| msg341937 - (view) | Author: Rémi Lapeyre (remi.lapeyre) * | Date: 2019-05-08 20:01 | |
If issue4356 is accepted, I think it may be possible to use `key=lambda e: -e`. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:14 | admin | set | github: 81038 |
| 2019-05-08 20:01:49 | remi.lapeyre | set | nosy:
+ remi.lapeyre messages: + msg341937 |
| 2019-05-08 19:50:08 | rhettinger | set | status: open -> closed messages: + msg341934 assignee: rhettinger |
| 2019-05-08 18:28:43 | xtreak | set | nosy:
+ rhettinger |
| 2019-05-08 18:11:15 | John Belmonte | create | |
