Like in most reasonable languages. Linked lists would be a terrible implementation for a list where grabbing arbitrary indices is explicitly supported.
And even then, many linked list implementations maintain an updated size or length because checking that is a pretty common operation. So even if that is the implementation, it would still be fast because len(list) is a very common operation so they’d definitely optimize it.
Like in most reasonable languages. Linked lists would be a terrible implementation for a list where grabbing arbitrary indices is explicitly supported.
And even then, many linked list implementations maintain an updated
size
orlength
because checking that is a pretty common operation. So even if that is the implementation, it would still be fast becauselen(list)
is a very common operation so they’d definitely optimize it.