I recently needed a doubly-linked list structure so implemented one in an array of (value, previous_ptr, next_ptr) tuples. It worked.
A little later and I re-solved my problem with a queue so used collections.deque. That worked too, and then read and was reminded that deque internals are based on a doubly-linked list it is just access is only given at each end.
That got me thinking. If new deque.start() and deque.end() returned DequePointer objects and that if ptr is of that type; ptr.next() and ptr.last() could return appropriate new DequePointer objects or None at the ends of the list.
ptr.value() could return the data at that location. There might also be a convenience function of ptr.items() returning a (ptr.value(), ptr.last(), ptr.next()) tuple.
Of course the normal identities would hold:
my_deque.start().value() == my_deque if len(my_deque) > 0
my_deque.start().next().value() == my_deque if len(my_deque) > 1
my_deque.end().value() == my_deque[-1] if len(my_deque) > 0
my_deque.end().last().value() == my_deque[-2] if len(my_deque) > 1
It might be better to have a separate class with the new functionality, but faster than Python execution based on the C-code for deque.
Useful to others? Too much bloat? these and other comments please.