I am looking for an implementation of a linked list and related algorithms for Python. Everyone I ask just recommend using Python's built-in lists, but performance measurements show that inserting and deleting a list is the bottleneck for our application. This is trivial for implementing a simple linked list, but I wonder if there is a mature library that includes some operations such as sorting, merging, merging, searching, lower / upper bounds, etc.
I know this is a hoax, but searching for a python list on any search engine gives predictable poor results, as most people just say that linked links are not needed in python (pfft!).
PS: I need to insert and delete from anywhere on the list, not just at the ends.
OK, you asked for this: I need to keep an ordered list of several hundred thousand entries. I will iterate the list forward (one by one) using the visitor on each record, starting from the beginning or position found by binary search. When a record matching the predicate is found, it is removed from the list, and then another binary search is performed in a subset of the list, starting from the previous position of the deleted record, until the position is determined statistically in advance. Ignoring the error condition, the modified entry can be used to create another linked list that is spliced to the new position found in the second binary search. The iteration continues from the position in which the entry was deleted. Sometimes, several thousand adjacent ordered records can be added or deleted from anywhere in the list. Sometimes it is necessary to search and delete several thousand non-contiguous records.
the python list is unacceptable since the insert / delete cost is prohibitive, and the small speed gains for binary search are completely out of line with the total cost. Our tests at home confirm this.
If I neglected any detail, perhaps I can send you a copy of my company’s non-disclosure agreement by e-mail, and I can privately correspond with you on this matter. sarcasm.end ().
python linked-list list algorithm
eclectocrat
source share