Antoine Pitrou added the comment:

My current use case is manipulation of Numba IR code. I'm working on a 
transformation pass that adds instructions at arbitrary places in existing IR. 
The primitive I need is "add an instruction after another one" (which is 
exactly the insert_after() primitive proposed here :-)). Since Python lacks a 
linked list-like structure, my current solution is to use a regular list, 
meaning O(n) inserts.

(a tedious solution with a regular list would be lazy inserts and batching)

The code has nothing special but you can see it here:
https://github.com/pitrou/numba/blob/7538d4c96b64a19691c2f9b6ec894f777db1a996/numba/ir.py#L538

It may be argued that the general problem more has to do with the lack of a 
linked-list structure rather than ordereddict itself. However, I can't think of 
a nice plain linked-list API in Python, while the ordereddict abstraction is 
adequate.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22097>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to